Using multithreading: What type of timer event should I use for a background process when my timer fires very quickly on newest questions tagged multithreading – Stack Overflow

I’m using a timer that can fire up to 5000 times a second. At the same time, the process that is running the timer will have spawned 32 threads of its own. Every time the timer fires, I want my threads to do something.

I can do this using any of the sigevent types (pulse, signal, or create a thread that sets a variable the other threads watch for), but I’m not sure which one would be most efficient.

I know threads are probably a bad idea as they are expensive and making so many every second will probably cause performance issues, so any ideas?

I would like it to perform the action ASAP once the timer has fired. So what’s the best type of event to use?

EDIT: Forgot to mention, this is coded in C

See Answers


source: http://stackoverflow.com/questions/11525791/what-type-of-timer-event-should-i-use-for-a-background-process-when-my-timer-fir
Using multithreading: using-multithreading



online applications demo