threadpool

specifying ThreadPoolExecutor problem

♀尐吖头ヾ 提交于 2019-12-07 06:41:58
问题 Is there any way to create Executor that will have always at least 5 threads, and maximum of 20 threads, and unbounded queue for tasks (meaning no task is rejected) I tried new ThreadPoolExecutor(5, 20, 60L, TimeUnit.SECONDS, queue) with all possibilities that I thought of for queue: new LinkedBlockingQueue() // never runs more than 5 threads new LinkedBlockingQueue(1000000) // runs more than 5 threads, only when there is more than 1000000 tasks waiting new ArrayBlockingQueue(1000000) // runs

Polling over thousands of TCP sockets

≯℡__Kan透↙ 提交于 2019-12-07 06:19:48
问题 I need to connect to thousands of clients over TCP on a proprietary protocol to acquire data cyclically. I need to write a .NET server application in C#. The first attempt was to create for each tcp socket an own thread, which works but needs a lot of cpu usage. I found out that it would be a better idea to use the .NET threadpool instead. As far as I understand (http://msdn.microsoft.com/en-us/library/ms973903.aspx) I could use timers in order to get each socket acquire the data cyclically

Design pattern to guarantee only one Runnable object of particular id value is being executed by the pool

蹲街弑〆低调 提交于 2019-12-07 05:09:46
问题 Suppose I have an ordered list of Runnable objects that are to be executed by ExecutorService . My Runnable objects have a userID filed - let's say I have about 20 different userId -s and 10 is the number of threads in the pool ( ExecutorService object). What is a general design pattern to ensure that at most 1 Runnable object of particular group is being executed in one of threads at one time? (The goal is that all Runnable from one id group should be executed cronologically and

When is specifying separate core and maximum pool sizes in ThreadPoolExecutor a good idea?

眉间皱痕 提交于 2019-12-07 04:37:40
问题 I'm trying to understand the point in specifying separate core and maximum pool sizes for Java 5's ThreadPoolExecutor. My understanding is that the number of threads is only increased once the queue is full, which seems a bit late (at least with larger queues). Isn't it that I'm either happy to allocate a larger number of threads to the tasks, in which case I might just increase the core pool size; or I am not really willing to do so, in which case I should rather have a larger queue? What is

Stopping a multi-threaded windows service

﹥>﹥吖頭↗ 提交于 2019-12-07 02:46:16
问题 I have a multi-thread windows service in .Net 3.5, and I am having some trouble to stop the service properly when more than one thread is created. This service used to create only one thread to do all the work, and I just changed it to be multi-threaded. It works perfectly, but when the service is stopped, if more than one thread is being executed, it will hang the service until all the threads are completed. When the service is started, I create a background thread to handle the main process

Thread keeps running even after application has been stopped in Websphere

佐手、 提交于 2019-12-07 00:26:04
问题 I have a long running thread which is created using org.springframework.scheduling.commonj.WorkManagerTaskExecutor with Spring and is running in Websphere Application Server 8. The problem is that this thread keeps running even if the application has been stopped. That thread needs to be stopped too but it is not happening. I even tried to use Thread.currentThread().isInterrupted() to check if the current thread was interrupted but it always returns false . So there is no way to know through

Does .NET ThreadPool thread get reset when it goes back to the pool?

两盒软妹~` 提交于 2019-12-06 19:10:40
问题 When a thread pool thread is done, does stuff like Name or thread local data get reset? So when the thread comes out of the pool next time, it's like brand new? Is there an "official" documentation on this aspect of the ThreadPool threads? 回答1: It does NOT clear thread local storage when it's released, which is the most important aspect to note. http://msdn.microsoft.com/en-us/library/system.threading.threadpool.aspx When the thread pool reuses a thread, it does not clear the data in thread

java thread pool keep running

只愿长相守 提交于 2019-12-06 13:42:05
This is more a generic question than a specific one. I'm trying to have a multi threaded environment that stays active so that I can just submit tasks and run them. I want to do this without the hassle of executing in a web server or application server. The idea was to use a java thread pool for this, but the issue here is that the pool stays open just until my main method finishes, after which obviously it closes and the program finishes. How can I prevent this from happening? I'm sure there are several options, some more naive than others (while true loops come to mind). Any ideas? Thanks.

Using multiprocessing for finding network paths

我怕爱的太早我们不能终老 提交于 2019-12-06 11:50:47
问题 I am currently using the networkx function *all_simple_paths* to find all paths within a network G, for a given set of source and target nodes. On larger/denser networks this process is incredibly intensive. I would like to know if multiprocessing could conceivably be used on this problem, and if anybody had any ideas on how that might be implemented, through creating a Pool etc. import networkx as nx G = nx.complete_graph(8) sources = [1,2] targets = [5,6,7] for target in targets: for source

WCF and threadpool responsiveness under high processor usage

大城市里の小女人 提交于 2019-12-06 11:49:51
We are having trouble controlling a long running process that uses WCF to send start/stop commands. The problem seems to be that WCF does not respond to the requests when the CPU load is high. Unfortunately, high CPU on as many cores as possible is necessary for the application in question as it needs to perform a large number of numeric calculations. Could the problem be related to the use of the thread pool to dispatch requests in WCF? This (somewhat dated) link suggests that it could: " we don't spin up new threads when CPU usage is higher than 80% " WCF has throttling mechanism that