• Welcome to Valhalla Legends Archive.
 

Threads, when to use and why?

Started by SecretShop, March 29, 2006, 01:37 PM

Previous topic - Next topic

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?

Yoni

On multiprocessor systems, if you run 1 thread per CPU, you utilize all CPUs.

MyndFyre

Quote from: SecretShop on March 29, 2006, 01:37 PM
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?

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).
QuoteEvery generation of humans believed it had all the answers it needed, except for a few mysteries they assumed would be solved at any moment. And they all believed their ancestors were simplistic and deluded. What are the odds that you are the first generation of humans who will understand reality?

After 3 years, it's on the horizon.  The new JinxBot, and BN#, the managed Battle.net Client library.

Quote from: chyea on January 16, 2009, 05:05 PM
You've just located global warming.

Banana fanna fo fanna

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?

Yegg

Quote from: Banana fanna fo fanna on April 06, 2006, 02:24 PM
OT: does anyone know a Scheme implementation with nonblocking I/O?

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.