threadpool

ThreadPool.SetMinThreads and SetMaxThreads and number of cores

只愿长相守 提交于 2019-12-11 01:07:01
问题 I am currently investigating Redis, and for tuning its capabilities, we need to change settings for ThreadPool, specifically minimum numbers of Worker/IOC threads. We're hosting application in Azure Web Role, as well as a part of it in a Worker Role. Reading documentation for asp.net, I found processModel.miniothreads element of web.config, which says: Configures the minimum number of I/O threads to use for the process on a per-CPU basis. Also see maxIoThreads. So technically, I read this as

ThreadPool behaviour: not growing from minimum size

十年热恋 提交于 2019-12-11 00:35:08
问题 I had set up my thread pool like this: ThreadPool.SetMaxThreads(10000, 10000); ThreadPool.SetMinThreads(20, 20); However, my app started hanging under heavy load. This seemed to be because worker tasks were not executing: I had used ThreadPool.QueueUserWorkItem to run some tasks which in turn used the same method to queue further work. This is obviously dangerous with a limited thread pool (a deadlock situation), but I am using a thread pool not to limit maximum threads but to reduce thread

ThreadPool thread doing I/O operation - can thread be reused while waiting?

落爺英雄遲暮 提交于 2019-12-10 23:45:01
问题 I have been reading a bit about async/await vs ThreadPool vs Threads, and I have to admit, I'm not fully clear on the details. There is one specific question that I think I have the answer to, but I can't say for sure. I am also aware of the many many questions on SO and elsewhere, where these questiosn are being discussed and explained. I have read a fair few here on SO, but I haven't found a clear answer, or at least as clear as I'd like. What I gathered: Using async/await in an I/O

How to reduce the time delay to reach run method of Runnable class using ExecutorService Java

好久不见. 提交于 2019-12-10 22:16:34
问题 I was trying to implement a real-time executing application in which a button click event will assign a task to a Thread , which will call a midi Method to play some music. The music has to be started immediately when button is clicked with a small delay. The midi codes are implemented in the run method of Runnable class. But to reach the 1st statement of run method after the button click event itself is taking more than 2 milli second . I tried to use Executor Service, since it can have

Tomcat memory usage grows in IDLE

﹥>﹥吖頭↗ 提交于 2019-12-10 20:47:21
问题 I have problem with growing memory consuming on Tomcat. Just after start nothing happens,but if some user login, after this memory usage start growing in Edem. PermGen does not grow, but anyway, it anormal. My analyze shows that thread RMI TCP Connection produces lot of Object[] char[] and String[] objects. I can not understand what's wrong and where to dig. Who starts this thread, is is postgres connections and what is this? 回答1: This is normal, and is NOT a memory leak. Objects are created

Waiting for all the tasks to finish

巧了我就是萌 提交于 2019-12-10 20:27:31
问题 I have a series of different "tasks" to be done using the same thread pool. I want to measure the time it takes to perform each task, but for that I need to wait for every task in the "task" (sorry for ambiguity) to finish. When there's just one task I would normally do this: ExecutorService e = Executors.newCachedThreadPool(); for (int i=0; i<100; ++i) e.submit(target); e.shutdown(); while (!e.isTerminated()); But since there will be several task submitted to the pool, I can't it down. All

C# Is it possible to interrupt a specific thread inside a ThreadPool?

可紊 提交于 2019-12-10 19:48:52
问题 Suppose that I've queued a work item in a ThreadPool , but the work item blocks if there is no data to process (reading from a BlockingQueue ). If the queue is empty and there will be no more work going into the queue, then I must call the Thread.Interrupt method if I want to interrupt the blocking task, but how does one do the same thing with a ThreadPool ? The code might look like this: void Run() { try { while(true) { blockingQueue.Dequeue(); doSomething(); } } finally { countDownLatch

Is it possible to use multithreading without creating Threads over and over again?

社会主义新天地 提交于 2019-12-10 19:28:19
问题 First and once more, thanks to all that already answered my question. I am not a very experienced programmer and it is my first experience with multithreading. I got an example that is working quite like my problem. I hope it could ease our case here. public class ThreadMeasuring { private static final int TASK_TIME = 1; //microseconds private static class Batch implements Runnable { CountDownLatch countDown; public Batch(CountDownLatch countDown) { this.countDown = countDown; } @Override

Java- FixedThreadPool with known pool size but unknown workers

爷,独闯天下 提交于 2019-12-10 18:15:34
问题 So I think I sort of understand how fixed thread pools work (using the Executor.fixedThreadPool built into Java), but from what I can see, there's usually a set number of jobs you want done and you know how many to when you start the program. For example int numWorkers = Integer.parseInt(args[0]); int threadPoolSize = Integer.parseInt(args[1]); ExecutorService tpes = Executors.newFixedThreadPool(threadPoolSize); WorkerThread[] workers = new WorkerThread[numWorkers]; for (int i = 0; i <

How to make delegate thread STA

痞子三分冷 提交于 2019-12-10 17:48:05
问题 I have see some discussion around this topic and concluded that it is not possible. I should use Threads, make it STA and when I need result back, join main thread with the created thread. This can work but it is not an ideal solution as using delegates I can achieve pure asynchronous behavior (using callback). So, to square one - just before I start implementing my own Future class (as in Java); Is there a better way to achieve this using delegates? private delegate String DelegateFoo(String