Can't you reuse the stream?
You can. But you need to encode the stream so that it does not end, and instead wait for more work. This is what the thread pool does.
Should I use ThreadPool?
If you want to reuse the stream, yes.
Why is Thread “better suited for longer operations” compared to ThreadPool?
Imagine a thread pool serving a large number of fast operations. You do not want to have too many threads, because the computer can do so many things at a time. Each long operation that you do with a thread pool binds a thread from the pool. Thus, the pool must have many additional threads or there may be fewer threads. None of them lead to the creation of an efficient pool of threads.
For longer operations, the overhead of creating and destroying a stream is very small compared to the cost of the operation. Thus, the normal disadvantage of using a thread for operation only is not applicable.
If you cannot reuse a stream, why use it at all (that is, what advantages does it offer)?
I assume that you are referring to the use of a thread dedicated to a task, which then completes using a thread pool. The advantage is that the number of threads will always be equal to the number of jobs in this way. This means that you need to create a thread every time you start a task, and destroy the thread every time you finish it, but you never have additional threads, and you never work with threads. (This may be good with I / O-related threads, but it may be bad if most threads are most commonly associated with CPUs.)
David schwartz
source share