Valhalla Legends Forums Archive | C/C++ Programming | Threads, when to use and why?

AuthorMessageTime
SecretShop
Heres a question, when writing a few programs I have been presented with the choice to use or not use threads.  Every time I usually choose not to and just multi-plex with some async calls.  Under what circumstances is it better or worse to use threads and why? What do you guys think?
March 29, 2006, 7:37 PM
Yoni
On multiprocessor systems, if you run 1 thread per CPU, you utilize all CPUs.
April 6, 2006, 6:49 PM
Myndfyr
[quote author=SecretShop link=topic=14614.msg149328#msg149328 date=1143661068]
Heres a question, when writing a few programs I have been presented with the choice to use or not use threads.  Every time I usually choose not to and just multi-plex with some async calls.  Under what circumstances is it better or worse to use threads and why? What do you guys think?
[/quote]

When you need to do a background task and not interrupt the GUI.  (This is common for print spooling or listening for data over the network).
April 6, 2006, 6:54 PM
St0rm.iD
Use non-blocking calls whenever possible (i.e. I/O) and IPC or threads when you need.

OT: does anyone know a Scheme implementation with nonblocking I/O?
April 6, 2006, 7:24 PM
Yegg
[quote author=Banana fanna fo fanna link=topic=14614.msg149963#msg149963 date=1144351499]
OT: does anyone know a Scheme implementation with nonblocking I/O?
[/quote]

Depending on what you're intersted in, have you tried CHICKEN? If you don't already know about it, it can easily interface with C.
April 6, 2006, 7:45 PM

Search