Implicit Threading

One way to address these difficulties and better support the design of multithreaded applications is to transfer the creation and management of threading from application developers to compilers and run-time libraries

Thread Pools

  • Whenever the server receives a request, it creates a separate thread to service the request.
  • Unlimited threads could exhaust system resources.
  • One solution to this problem is to use a thread pool.

The general idea behind a thread pool is to create a number of threads at process startup and place them into a pool, where they sit and wait for work. When server receives a request, it awakens a thread from this pool, and pass it the request for service. Once the thread completes its service, it returns to the pool and awaits more work. If the pool contains no available thread, the server waits until one becomes available.

Thread pool benefits

  • Servicing a request with an existing thread is faster than waiting to create a thread.
  • A thread pool limits the number of threads that exist at any one point.
  • Separating the task to be performed from the mechanics of creating the task allows us to use different strategies for running the task.

results matching ""

    No results matching ""