Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Which thread library should I use for multithreaded C programs on Linux?

I've done threads in Java, but I'm a complete noob to threads in C. My first question, after googling some, is: Which thread library do I use? Does it matter? It seems I have thread.h and pthread.h to choose from.

OS is, and will be, Linux. More specifically, it's Ubuntu at the moment and will either stay like that, or become RHEL. But I guess the distro doesn't matter?

like image 226
Hanno Fietz Avatar asked Mar 09 '11 15:03

Hanno Fietz


2 Answers

The POSIX thread libraries (pthread.h) are a standards based thread API for C/C++ and is what I would use. There are also several tutorials available such as this one or this one.

I will admit that I am not familiar with thread.h.

like image 163
jschmier Avatar answered Sep 18 '22 12:09

jschmier


The standard thread interface on POSIX systems such as linux is pthread, for POSIX thread.

like image 25
Jens Gustedt Avatar answered Sep 22 '22 12:09

Jens Gustedt