I'm not looking for high performance as I am managing lots of TCP socket connections and not a UDP thing, however I don't want to make any clearly bad practice moves as i am being marked however its just on c++ only (threads and net connections aren't taught yet so I get bonus points for the bones).
this is the code im trying to avoid calling in a thread
First one is faster. When you create a thread, there's a delay before it is *actually* ready to be used. The delay is usually a significant one.
The first thread should NOT busy-wait though, as it will eat a lot of computing power that way.
Use a mutex, they can avoid busy-waits and they don't cost as much as a full thread.
Yes, creating threads is expensive. Some libraries do what SGH suggested automatically and encapsulate it as thread pools. Basically, you just create a bunch of threads in advance and make them wait. Then other threads can give them tasks asynchronously, which is much faster than creating a thread for each individual task.
The Microsoft library: excellent performance, uses kernel thread pools
The LLVM library (libc++): acceptable performance, uses thread pools simulated in user mode
The GNU library (libstdc++): there is no library support for thread pools
Someone's been going through and reporting him. Some people just don't know how to act mature.
Thankfully, everyone knows how helpful JLBorges is, so nothing will happen to him.