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


Human Verification: In order to verify that you are a human and not a spam bot, please enter the answer into the following box below based on the instructions contained in the graphic.

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

Please click below to support us on Facebook!

Send this to a friend

▷ Other ReviewsVehicles   Show Cars   Motorbikes   Scooters   Bicycles   Rims & Tires   Luxury BoatsFashion   Sunglasses   Luxury Watches   Luxury Purses   Jeans Wear   High Heels   Kinis Swimwear   Perfumes   Jewellery   Cosmetics   Shaving Helpers   Fashion Hats   Modeling TipsFooding   Chef Club   Fooding Helpers   Coktails & LiquorsSports   Sport Shoes   Fitness & Detox   Golf Gear   Racquets   Hiking & Trek Gear   Diving Equipment   Ski Gear   Snowboards   Surf Boards   Rollers & SkatesEntertainment   DIY Guides   Zik Instruments   Published Books   Music Albums   Cine Movies   Trading Helpers   Make Money   Fishing Equipment   Paintball Supplies   Trading Card Games   Telescopes   Knives   Vapes   GameplaysHigh Tech   Flat Screens   Tech Devices   Camera Lenses   Audio HiFi   Printers   USB Devices   PC Hardware   Network Gear   Cloud Servers   Software Helpers   Programmer Helpers   Mobile Apps   Hearing AidsHome   Home Furniture   Home Appliances   Tools Workshop   Beddings   Floor Layings   Barbecues   Aquarium Gear   Safe Boxes   Office Supplies   Security Locks   Cleaning ProductsKids   Baby Strollers   Child Car Seats   Remote ControlledTravel   Luggages & Bags   Airlines Seats   Hotel Rooms   Fun Trips   Cruise Ships   Mexico Tours