Questions tagged [threadpool]

A thread pool is a method to reuse existing threads, rather than always creating new ones. They allow for pooling resources in given limits and automatically assigning tasks to open workers. Use this tag when you have questions about implementing a thread pool, or using an existing thread pool implementation.

In multi-threaded applications, handling the various threads is a complicated task. Thread pool functionality is targeted to make it easier to use a large number of threads efficiently.

Because thread creation is relatively expensive, reusing threads in a pool can increase a programs performance. It can also help make better use of the available hardware threads by limiting the total number of threads that are created.

The main goal when using a thread pool is to be able to dynamically schedule work to a given set of workers. However, the original thread does not need to keep track of the thread creation itself, but forwards the thread management to the thread pool implementation. The thread pool will create new workers if necessary and destroy unused ones.

References

Related tags

4676 questions
2
votes
2 answers

ThreadPool - WaitAll 64 Handle Limit

I am trying to bypass the the wait64 handle limit that .net 3.5 imposes I have seen this thread : Workaround for the WaitHandle.WaitAll 64 handle limit? So I understand the general idea but I am having difficulty because I am not using a delegate…
bearrito
  • 41
  • 1
  • 4
2
votes
3 answers

Is it possible to create a deadlock in C# if nothing but the lock keyword is used around primitive data access?

I've written a lot of multi-threaded C# code, and I've never had a deadlock in any code I've released. I use the following rules of thumb: I tend to use nothing but the lock keyword (I also use other techniques such as reader/writer locks, but…
Contango
  • 76,540
  • 58
  • 260
  • 305
2
votes
1 answer

Sending Exchange WS emails - Not enough free threads in the ThreadPool to complete the operation

I need to overcome this error: There were not enough free threads in the ThreadPool to complete the operation. I get it 80% of the time when queuing a bunch of Correspondence objects (with SSRS Reports) and sending them via Exchange WS. The…
Jeremy Thompson
  • 61,933
  • 36
  • 195
  • 321
2
votes
1 answer

Conditional delayed processing

I have created a new thread pool and a new associated listener under glassfish. The thread pool has a maximum capacity of 100 threads. I have a scheduled job running every night which should trigger a HTTP GET request from remote client. Note that…
2
votes
1 answer

Does the JVM limit the number of threads an Executor can run?

I know I can use a fixedThreadPool to limit the amount of threads my program uses at one time. If I use a cachedThreadPool and could run 10,000 threads, will the JVM schedule them appropriately so not too many are running at the same time?
Nick
  • 1,743
  • 6
  • 23
  • 38
2
votes
2 answers

WCF not handle 1000 call per second

I am working on a WCF Service that is hosted in Windows Service, using nettcpbinding. when i tried to perform load test on the service i built a simple client that call the service about 1000 call in second, the return from the service take about 2…
mkalashy
  • 103
  • 1
  • 4
2
votes
2 answers

Consequence of too many unused blocked threads

I want to clear my concept on unused threads effect.What is the overall effect of too many unused blocked threads in the thread pool. Suppose I have a thread pool having 100 threads in which 50 are unused and waiting for request to process but the…
faisal bahadur
  • 97
  • 1
  • 1
  • 7
2
votes
2 answers

Trying to resolve scalability issues by gating simultaneous requests

I have a legacy application that needs to deal with scalability issues. This is a WCF service that listens to requests received from a back end system and does some computations/processing of data based on those requests. The computations are not…
2
votes
2 answers

Is it possible to have a set of thread pools that share threads from a large thread pool instead of creating new thread?

Is it possible to have a set of thread pools that share threads from a large thread pool instead of creating new thread? In our RESTful API application, a request may involve several parallel tasks. To improve the performance, we want to execute…
2
votes
1 answer

Embedding Jetty 9 and customizing Socket Address, Port and ThreadPool?

I have previously used Jetty 8.1.14 as embedded web server in my application. Now I am trying to upgrade to version 9.2.10. With Jetty 8, it was possible to specify the Host Address and Port using the setters in the "SelectChannelConnector" or…
dkessel
  • 43
  • 8
2
votes
1 answer

Java: guide-line for when to use thread-pooling?

This is a high-volume production system, however, this particular code path is seldom used. Its an import feature that can potential result in a lot data coming in, but it's only occasionally used, a few times a month, perhaps. Having a (polite)…
mtyson
  • 8,196
  • 16
  • 66
  • 106
2
votes
3 answers

Goroutines 8kb and windows OS thread 1 mb

As windows user, I know that OS threads consume ~1 Mb of memory due to By default, Windows allocates 1 MB of memory for each thread’s user-mode stack. How does golang use ~8kb of memory for each goroutine, if OS thread is much more gluttonous. Are…
Ark
  • 1,343
  • 2
  • 12
  • 26
2
votes
1 answer

Number of available threads in threadpool

In a Threadpool, I have set maximum number of threads.I want number of worker threads are available. i tried. ThreadPool.GetAvailableThreads(out x, out y); Using this, I got number of available threads (x) which was only decreasing.There was…
Kaustubh_Kharche
  • 725
  • 3
  • 13
  • 34
2
votes
2 answers

Java: execute Runnable fixed number of times

So I have a piece of code that I want to execute repeatedly. I get this part. The problem is that I want to execute the code at fixed intervals, but only a fixed number (in this case 1440) times. Any ideas how I'd do that? Here's the code: import…
Ben Lawton
  • 149
  • 1
  • 13
2
votes
3 answers

Customized multithreading: limiting number of tasks of some type to be executed in parallel, without limiting tasks of other types

I have tasks of 3 types: A, B, C. And I want to run those tasks in parallel in N threads. Let's suppose, that the list of tasks is the following: A, B, C, B, C, A, B, C Of course, I can achieve multithreading execution using ExecutorService But the…
Madhan
  • 5,750
  • 4
  • 28
  • 61