|
-
Dec 9th, 2002, 07:09 AM
#1
Thread Starter
Lively Member
Threading in C++
can you please let me know how to make threads in c/c++.
-
Dec 9th, 2002, 10:36 AM
#2
Two approaches:
a) OS-dependent: threading is something highly OS-dependent. POSIX threads work completly different than Windows threads.
For windows, look at the CreateThread function and related functions, as well as _beginthread and _beginthreadex. For POSIX look at clone.
This let's you wield the full power that the OS offers, but you can't write portable code this way.
b) OS-independent: the boost project ( www.boost.org ) has a C++ class library that offers a platform independent interface to threading. The advantage is portable code that integrates well with the C++ Standard Library. The disadvantage is that it is more or less the largest common denominator: It supports mutexes and critical sections, but not much more in the way of synchronization, and I don't know if it has thread local storage. But for simple console-based multi-threaded apps it's perfect.
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|