7

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?

5
  • Where on the filesystem do you have thread.h ? Commented Mar 9, 2011 at 19:03
  • @pilcrow - didn't look in the file system, saw it in some tutorials, with methods like thr_create. It doesn't appear to be widespread, or maybe I got something wrong. I'm using pthreads now, so it doesn't matter anymore. Commented Mar 9, 2011 at 22:03
  • That's probably the native thread API of SunOS/Solaris, which might have answered your question right off the bat. :) Commented Mar 9, 2011 at 22:18
  • @pilcrow - You are very probably right. :) Commented Mar 9, 2011 at 22:36
  • The answer to this question helped me to overcome web search confusion, and after doing a lot of reading on POSIX threads, I realize just how newbie this question is. Hope it helps other noobs. Commented Mar 9, 2011 at 22:47

2 Answers 2

12

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.

Sign up to request clarification or add additional context in comments.

Comments

1

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.