threadpool

java Callable FutureTask Excecuter: How to listen to finished task

瘦欲@ 提交于 2019-12-30 03:19:11
问题 I'm quite new to executer services. Liked doing everything myself, but I think it's time to trust these services. I want to hand by Executer a Runnable . The executer wraps that in a FutureTask and hands it back to me. Now I call poll the done() method. But I would like to be notified when then done() method would return true. There is a get() method that blocks until the Runnable has finished, but then I would need a extra thread for every job, just to see when it's finished. Can I hand my

Doubts in the code of Thread Pool implementation

China☆狼群 提交于 2019-12-29 09:27:25
问题 After spending lots of time with threadpool concepts and by reading different codes on numbers of blogs and posting questions on Stackoverflow.com, now I got clear image of this concept. But in the meanwhile, I found some doubts in code. When pool.assign(new TestWorkerThread()); executes in TestThreadPool Class, it calls done.workerBegin(); method that is in Done Class , where it increments _activeThreads variable. But what I thinks is, LOGICALLY that is not correct because if number of

Using tasks/ ThreadPool on IIS application (asp .net)

孤者浪人 提交于 2019-12-29 07:21:42
问题 We have an asp.net application on an iis 7. we need to create an async process to do calculating (using a web service) and not keeping the client waiting, we used ThreadPool to do that (i prefer Tasks but i am a server side guy). My questions are : 1. if using a thread pool on iis does it take threads from the iis pool from clients or from the OS ? 2. What would you use Tasks or ThreadPool (Tasks give you much more i know but the UI guys like the pool). Tanks 回答1: The ASP.NET host provides a

Using tasks/ ThreadPool on IIS application (asp .net)

爱⌒轻易说出口 提交于 2019-12-29 07:21:21
问题 We have an asp.net application on an iis 7. we need to create an async process to do calculating (using a web service) and not keeping the client waiting, we used ThreadPool to do that (i prefer Tasks but i am a server side guy). My questions are : 1. if using a thread pool on iis does it take threads from the iis pool from clients or from the OS ? 2. What would you use Tasks or ThreadPool (Tasks give you much more i know but the UI guys like the pool). Tanks 回答1: The ASP.NET host provides a

How to wait for a ThreadPoolExecutor to finish

丶灬走出姿态 提交于 2019-12-29 03:29:21
问题 My Question: How to execute a bunch of threaded objects on a ThreadPoolExecutor and wait for them all to finish before moving on? I'm new to ThreadPoolExecutor. So this code is a test to learn how it works. Right now I don't even fill the BlockingQueue with the objects because I don't understand how to start the queue without calling execute() with another RunnableObject . Anyway, right now I just call awaitTermination() but I think I'm still missing something. Any tips would be great! Thanks

Pre-initializing a pool of worker threads to reuse connection objects (sockets)

白昼怎懂夜的黑 提交于 2019-12-29 03:29:13
问题 I need to build a pool of workers in Java where each worker has its own connected socket; when the worker thread runs, it uses the socket but keeps it open to reuse later. We decided on this approach because the overhead associated with creating, connecting, and destroying sockets on an ad-hoc basis required too much overhead, so we need a method by which a pool of workers are pre-initializaed with their socket connection, ready to take on work while keeping the socket resources safe from

Cross-thread operation not valid in Windows Forms

…衆ロ難τιáo~ 提交于 2019-12-29 01:39:50
问题 Could anyone help me i have a problem I'm trying to get this code to work in the background via threadpool but i cannot seem to get it to work i keep getting this error: Cross-thread operation not valid: Control 'ListBox3' accessed from a thread other than the thread it was created on. Here is the code i am using: private void DoWork(object o) { var list = ListBox3; var request = createRequest(TxtServer.Text, WebRequestMethods.Ftp.ListDirectory); using (var response = (FtpWebResponse)request

Cross-thread operation not valid in Windows Forms

十年热恋 提交于 2019-12-29 01:39:26
问题 Could anyone help me i have a problem I'm trying to get this code to work in the background via threadpool but i cannot seem to get it to work i keep getting this error: Cross-thread operation not valid: Control 'ListBox3' accessed from a thread other than the thread it was created on. Here is the code i am using: private void DoWork(object o) { var list = ListBox3; var request = createRequest(TxtServer.Text, WebRequestMethods.Ftp.ListDirectory); using (var response = (FtpWebResponse)request

How to increase thread-pool threads on IIS 7.0

让人想犯罪 __ 提交于 2019-12-28 12:00:32
问题 Environment: Windows Server 2008 Enterprise, IIS 7.0, ASP.NET 2.0 (CLR), .NET 4.0 I have an ASP.NET application with no page and no session( HttpHandler ). It a streaming server. I use two threads for processing each request so if there are 100 connected clients, then 200 threads are used. This is a dedicated server and there's no more application on the server. The problem is after 200 clients are connected (under stress testing) application refuses new clients, but if I increase the worker

Why *not* change the priority of a ThreadPool (or Task) thread?

你说的曾经没有我的故事 提交于 2019-12-28 06:28:09
问题 There are many places across the web and Stack Overflow where one is discouraged from changing the priority of a ThreadPool thread or TPL Task . In particular: "You have no control over the state and priority of a thread pool thread." "The runtime manages the thread pool. You have no control over the scheduling of the thread, nor can you change the thread's priority." "You should not change the Culture or Priority or... of a PoolThread. Just like you don't paint or re-decorate a rental car."