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
0 answers

Have Tomcat handle websocket calls in parallel, using different threads

I have a Tomcat 8 websocket application and noticed a certain behavior when handling websocket client calls. Some details: http-nio-8080-exec-3 - 18:50:56 <-- this takes 30 seconds http-nio-8080-exec-3 - 18:50:56 <--+ http-nio-8080-exec-3 - 18:50:56…
bdem
  • 321
  • 1
  • 6
2
votes
2 answers

How to add new tasks to threadpool only when all the tasks are finished using boost in c++

boost::asio::io_service ioService; boost::thread_group threadpool; boost::barrier barrier(5); boost::asio::io_service::work work(ioService); threadpool.create_thread(boost::bind(&boost::asio::io_service::run, &ioService)); //Thread…
USer22999299
  • 5,284
  • 9
  • 46
  • 78
2
votes
1 answer

More TCPClients per Thread or More Threads

I need some guidance on a project we are developing. When triggered, my program needs to contact 1,000 devices by TCP and exchange about 200 bytes of information. All the clients are wireless on a private network. The majority of the time the…
Bernie Hunt
  • 306
  • 4
  • 22
2
votes
0 answers

Python Using multiprocessing.pool with mpi4py generates Cannot allocate memory error

I am working on a cluster of computers, and recently started using parallel programming with python. My current understanding is: mpi4py helps to manage work between different nodes, and multiprocessing manages work in a node's cores. I have divided…
2
votes
0 answers

How does Nginx communicate with upstreames?

Nginx uses epoll to communicate clients and it's very efficient, but how Nginx communicate with upstreams, I google and get a answer from quora http://www.quora.com/How-can-nginx-handle-concurrent-requests-with-a-single-worker-process, but the…
windrain
  • 75
  • 2
  • 9
2
votes
2 answers

Where to use Thread interupt

I have some old code I am working with, and I'm not too experienced with Threads (mostly work on the front end). Anyway, this Thread.sleep is causing the thread to hang and I'm unsure what to do about it. I thought about using a counter and…
Jackson Bray
  • 235
  • 2
  • 7
  • 17
2
votes
2 answers

Java - How to log metrics from a ThreadPool?

I wrapped a ThreadPoolExecutor in an implementation of ExecutorService of my own, just to send it any filesystem writing task, so they would be treated sequencially and one-by-one. (No need to harass this poor disk writing head.) The wrapper comes…
Silver Quettier
  • 2,045
  • 2
  • 26
  • 53
2
votes
1 answer

How to make join on boost::asio::io_service?

Here is the problem: In the main thread (io - boost::asio::io_service): io.post(functor1, callback1) .... io.post(functorN, callbackN) io.join() <--- waiting while all the task to be processed and continue to execute the program The code is…
fogbit
  • 1,961
  • 6
  • 27
  • 41
2
votes
1 answer

PerThreadLifetimeManager in Unity

In the Unity PerThreadLifetimeManager documentation, I read that: "This lifetime manager does not dispose the instances it holds". Ref.: http://msdn.microsoft.com/en-us/library/ff647854.aspx So, if I am using a ThreadPool, does it mean that objects…
DorianGrey
  • 23
  • 1
  • 3
2
votes
3 answers

Is my understanding of the C# threadpool correct?

I'm reading Essential C# 5.0 which says, The thread pool also assumes that all the work will be relatively short-running (that is, consuming milliseconds or seconds of processor time, not hours or days). By making this assumption, it can…
GrowinMan
  • 4,891
  • 12
  • 41
  • 58
2
votes
2 answers

Handling Thread pool isolation?

Goal I want to understand how to handle two thread pools simultaneously in java? Consider a client server system in which clients are sending blocking I/O requests to the server (for example a file server ). There is a single ThreadPoolExecutor …
2
votes
2 answers

C Thread pool - passing argument duplicate

Having the source code below: #define THREAD 32 #define QUEUE 300 #include #include #include #include #include "threadpool.h" struct fparam { int no; }; int tasks = 0, done = 0; pthread_mutex_t…
2
votes
1 answer

Calling same method multiple times and show progress

I have a stored procedure which can run dynamic query and produce a result set to static table. which in return will look like below (conceptually) I can display result to the user via SQL Dependency or node.js but I want to understand how exactly…
Zerotoinfinity
  • 6,290
  • 32
  • 130
  • 206
2
votes
0 answers

Multi thread to process data and realtime display, thread and lock design in Python

There is data to be displayed to user and function to process them. Each time the user interacts with the data, the function must be run on all the data and the result is displayed to the user. This should work multithreaded so there is no user…
Jerryno
  • 891
  • 8
  • 16
2
votes
3 answers

Which is faster? Less work in more runnables, or more work in less runnables? (ExecutorService)

I'm trying to figure out how I can get the maximum performance from a multithreaded app. I have a thread pool which I created like this: ExecutorService executor = Executors.newFixedThreadPool(8); // I have 8 CPU cores. My question is, should I…
Utku Ufuk
  • 318
  • 1
  • 10
  • 24