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
1 answer

Glassfish set max number of concurrent Batch Jobs

GlassFish allows you to tune the global EJB pool size, as well as specific pool sizes per EJB. By setting the max-pool-size under glassfish-ejb-jar.xml I can control how many instances of a EJB can be used in parallel.
Anthony Accioly
  • 21,918
  • 9
  • 70
  • 118
2
votes
1 answer

bounded-queue-thread-pool threads not getting terminated on jboss shutdown

I have created a bounded-queue-thread-pool in Jboss 7.2.0 standalone.xml as follows:
keenUser
  • 1,279
  • 3
  • 16
  • 33
2
votes
1 answer

Where does the worker thread come from on an async MVC action?

Imagine this action: public async Task MyAction(){ var result = await MyMethodAsync(); return View(result); } I understand that by making the action async, you release the thread executing the action back to the thread pool…
AxiomaticNexus
  • 6,190
  • 3
  • 41
  • 61
2
votes
1 answer

When does Tomcat increase the number of threads?

Tomcat increases the number of threads from minSpareThreads to maxThreads step by step. What is the trigger that makes Tomcat increase the number of threads?
Johnny Lim
  • 5,623
  • 8
  • 38
  • 53
2
votes
2 answers

Ruby: Any gems for threadpooling?

Is there a gem for threadpooling anyone can recommend?
Zombies
  • 25,039
  • 43
  • 140
  • 225
2
votes
0 answers

Clean ThreadLocal data when thread is returned to ThreadPool

I read few webpages with similar issue but nobody post working solution. Therefore I am trying my luck here. I have simple application where I need to clear ThreadLocal data when worker thread is returned to ThreadPool. class Program { private…
user2126375
  • 1,594
  • 12
  • 29
2
votes
2 answers

C++ Thread execution order in a thread pool

Does anyone know of a C++ thread pool implementation that allows both parallel threading (like a typical thread pool) but also allows for back to back serial execution order. I have spent several days trying to make this work by modifying the…
johnco3
  • 2,401
  • 4
  • 35
  • 67
2
votes
2 answers

run threads according to the time limit

I want to start max 40 http requests each second and after 1 second, I want it to run another 40 from its own queue(like threadpooltaskexecutor's blocking queue). I am looking for an executor or thread pool implementation for this requirement. Any…
Neron
  • 1,500
  • 7
  • 30
  • 52
2
votes
1 answer

Program never ends when use other implementation of Execution Context for Futures

import java.util.concurrent.Executors import scala.concurrent._ import scala.util.{Failure, Success} import scala.concurrent.duration.DurationInt import scala.language.postfixOps object Test extends App { println("start") implicit val ec:…
coffee
  • 3,048
  • 4
  • 32
  • 46
2
votes
2 answers

How many Runnable's can be added to the queue in a fixed/cached Thread Pool?

Is there practically any limit on how many number of Runnable's that can be added to the queue in a fixed/cached Thread Pool of say 10 worker Threads..?? In my application, I am trying to add 100000 Runnable's. for (int i=0; i<100000; i++) { …
surendhar_s
  • 824
  • 2
  • 12
  • 20
2
votes
1 answer

Java: multithreading on massive data: sharing data between threads?

I want to run a multithreaded program on massive data. I usually create a class which is callable (or runnable) and pass the data needed for the process to the class. public class CallableTrainer implements Callable { dataType…
Daniel
  • 5,839
  • 9
  • 46
  • 85
2
votes
1 answer

Android java.util.concurrent.RejectedExecutionException: Task android.os.AsyncTask rejected from java.util.concurrent

i am creating asynchtask on thread pool on an listview . i am handling those task through an listarray of asynchtask . i have to remove those task when fragments get destroy and have to again assign those task when i make new fragment after…
Muhammad Adil
  • 4,358
  • 3
  • 32
  • 36
2
votes
4 answers

Safe ThreadPool Queueing with Parameters in VB.NET (WinForms)

I know how to use BackgroundWorker (gui object in WinForms designer), and to manually instantiate Threads that elevate the custom event to the UI, however, I am having some trouble figuring out how to use the ThreadPool object (simplest form) to…
Kraang Prime
  • 9,981
  • 10
  • 58
  • 124
2
votes
2 answers

How to resolve "Connect: operation timed out" and "RetryExec" error?

My Java program sends one thousand URL to a server and try to fetch result. I started getting this result. How to resolve this? The code is given in this question Why does the following executor service java Thread program doesn't shut down? …
sofs1
  • 3,834
  • 11
  • 51
  • 89
2
votes
2 answers

ThreadPool with 2 WaitCallback will sometimes be stuck

I'm trying to work with ThreadPool.QueueUserWorkItem but it seems that if i'll run 2 of them, meaning: ThreadPool.QueueUserWorkItem(new WaitCallback(x=>function A); ThreadPool.QueueUserWorkItem(new WaitCallback(x=>function B); It sometimes will be…
Avi Levin
  • 1,868
  • 23
  • 32
1 2 3
99
100