Saturday, August 18, 2007

Thread from the thread pool or dedicated thread.

Use thread from the thread pool to execute some asynchronous task instead of a dedicated thread can save the resources needed to create that dedicated thread.

A dedicated thread is only needed if the thread needs to run in a special priority, since all the threads from the thread pool are running in the normal priority, and you don't have access to change the priority for the thread in the thread pool.

Another reason is that if the thread needs to be run in foreground, a dedicated thread is also needed since all the threads in the thread pool are running in the background.

If the task is taking extremely long time to finish, then a dedicated thread is also needed because it is a little bit challenging for the thread pool to figure out whether to create additional thread when that task is running.

No comments: