Subj : Threading strategy To : comp.programming.threads From : b.fokke Date : Thu Apr 07 2005 08:24 am Hi, I'm writing process operating software and I have a question regarding Multi threading strategy. The machine has a couple of subsystems. The machine produces units, which have to pass these subsystems in sequential order. Since the time each subsystem takes to complete its job varies, there are buffers between the subsystems. Basically there are two different approaches: - Use one thread per unit. The code would look something like this: class UnitWorkThread { void work() { doSubSystem1(); waitForSubSystem2(); doSubSystem2(); waitForSubSystem3(); doSubSystem3(); } } i.e. The lifecycle of this thread resembles the lifecycle of a single unit of production. - The other approach is to use one thread per subsystem. Each subsystem thread would look something like this: class SubsystemThread { void work() { waitForUnit(); doActualWork(); } } There are advantages to each approach. The second approach uses a finite, known number of threads so starting, stopping and generally controlling the state of all subsystems becomes a lot easier. However, the first approach looks easier to synchronize. Furthermore, I haven't got a clue which approach would be better in terms of performance. Is there anyone who has any experience and would like to share a bit of wisdom? Any pointers would be greatly appreciated! Thanks in advance, Bram Fokke .