C Programming in Linux Tutorial #029 – pthreads

C Programming in Linux Tutorial using GCC compiler. Tutorial should also be applicable in C/UNIX programming. An example on how to create threads using the POSIX threads, or pthreads.


Nishant Patil says:

Thanks man this helped me in my assignment!

pritul dave says:

In my this is first printing for thread 2 and then thread 1

Shahzad Ahmad says:

How can char store string value? In my program can’t work correct I don’t know how to deal with it

Abhinav Kr says:


Diseño - Software Libre says:

This is so interesting. Way to go!!

Max Kanushin says:


karan katyal says:

Does the threads print the two printf statements after pthread_join?
I see no ret1 = or ret 2 = in the output

Duca ϋ says:

it’s great!!
btw how to copy a similar line that fast?

like 2:58
any hot key in vi?


Alexander Balkoni says:

mr Mackey is that you ?

Emrah E says:

Finally a clear explanation with multiple threads running. Thanks for uploading

Muhamed Ahmed says:

einfach toll

3GenGames says:

Bad code but nice tutorial to look at what code we can expect to need.

Steve Erikson says:

You don’t have to (and shouldn’t, honestly) cast ‘myvar’ to ‘(char *)’ because void pointers are safely and automatically promoted to any other pointer type. You actually don’t even need the ‘msg’ variable at all; you can just as easily do `printf(“%s %dn”, (char *)myvar, i);`. You also should _always_ be compiling with ‘-Wall’ and ‘-Wextra’, because if you did you would see that you are not properly including the header file for ‘sleep()’. ‘sleep()’ is declared in ‘‘, not ‘‘. Also, you should use the gcc option ‘-pthread’ for pthread support (or the synonymous ‘-pthreads’) rather than ‘-lpthread’, it does more than link the library (check the gcc man page if you’re interested in the specifics), it does everything necessary to get you full pthread functionality (and even just looking at the man page you have open in this vid. for ‘pthread_create’, it says to compile & link with ‘-pthread’; it doesn’t mention ‘-lpthread’). Other than that, good video, thanks :).

Silvers Rayleigh says:

Are you a professional programmer? Great skills, thanks for tutorial.

Sam Arutyunyan says:

great vid, thanks!

Omar Balfaqih says:

Thanks for the tutorial !

Shant Abraham says:

Thanks, very helpful and clear explanation! 🙂

 Write a comment


Do you like our videos?
Do you want to see more like that?

Please click below to support us on Facebook!