3 ms·
I'm a noob to concurrency, but my current understanding is that a "thread" is "virtual". Fundamentally, your CPU has finite cores so no matter how many threads
by yomly 9y ago
I'm a noob to concurrency, but my current understanding is that a "thread" is "virtual". Fundamentally, your CPU has finite cores so no matter how many threads you spawn your (individual) CPU cores will resolve the threads into a synchronous set of instructions to execute.
Having a single threaded (asynchronous) server simply displaces the abstraction of threads.
Please feel free to correct if I'm wrong about this...
- gpderetta 9y agoYes, but you need at least as many thread or processes as you have cores to take advantage of them. A multicore cpu is wasted on single threaded program unless you are lucky enough that your problem is so embarassingly parallel that can be handled by N indipendent the processes
- dahart 9y agoNo, async & single-threaded is not an abstract replacement for threads. Single-threaded async code can only use 1 CPU core at a time. For example, JS running in the browser without web workers. Multi-threaded uses multiple cores simultaneously. Whether a thread is "virtual" - I don't know what that means to you, but threads are a primitive the OS provides. Some CPUs have hardware support for threads, and some don't. So, I suspect they are less virtual than you're thinking.