April 2018
Intermediate to advanced
300 pages
7h 41m
English
Creating a new thread for each task without monitoring or aborting the lifecycle of the thread is a bad practice. Threads are good to perform multitasking and to utilize multiple resources of the server to run things in parallel. However, if the design is to create threads for each request, this can slow down the application's performance, as the CPU will take more time in the context of switching between the threads rather than executing the actual job.
Whenever we use threads, we should always try to keep a shared thread pool where any new item that needs to be executed waits in the queue if the thread is busy, and is acquired when it is available. This way, thread management is easy and server resources ...