C/C++‎ > ‎

Threads

Simple example programs using threads, mutex and logging:

Threads with POSIX:
http://en.wikipedia.org/wiki/POSIX_Threads
Start and run with:
 $ g++ -Wall -O3 pthreads.cpp -o pthreads -lpthread; ./pthreads

+ simple, join() exists
- runs only under POSIX OS

Threads with Qt:
http://doc.trolltech.com/latest/qthreadpool.html
Start and run with:
 $ tar -xzf qthreads.tar.gz
 $ cd qthreads/
 $ qmake; make; ./qthreads

+ runs under OS which have Qt, signal & slot capable
- join() is called wait()

Threads with Boost:
http://www.boost.org/doc/libs/1_44_0/doc/html/thread.html
Start and run with:
 $ g++ -Wall -O3 bthreads.cpp -o bthreads -lboost_thread-mt; ./bthreads

+ runs under OS which have boost, elaborate, join() exists
- constructor starts the thread


Update: Boost threads are now handled with thread_group (Thanks, João!).
Update2: Qt threads are handled by QThreadpool now (Again thanks, João!).

Č
ċ
bthreads.cpp
(4k)
El Samuko,
Nov 12, 2010, 12:46 AM
ċ
pthreads.cpp
(4k)
El Samuko,
Nov 10, 2010, 3:35 AM
ċ
qthreads.tar.gz
(2k)
El Samuko,
Nov 12, 2010, 1:16 AM
Comments