threadpool

Best way to wait on tasks to complete before adding new ones to threadpool in Java?

断了今生、忘了曾经 提交于 2020-01-03 05:08:13
问题 I want to use something like a ThreadPoolExecutor to manage running a bunch of tasks on available threads. These tasks are all of the same type but deal with different accounts. New tasks for these accounts can be added at regular intervals and I want it to check and not allow the new tasks to start until the old tasks for the same account have already completed. What's the best way to do this? EXAMPLE Task for account "234" is started (via ThreadPoolExecutor.execute()) Task for account "238"

See lots of clr!CLRSemaphore::Wait in call stack

纵饮孤独 提交于 2020-01-02 19:28:10
问题 We see lots of callstack like the below, may I know what's conditions \situation would happens this? OS Thread Id: 0x48654 (559) Current frame: ntdll!NtWaitForSingleObject+0xa Child-SP RetAddr Caller, Callee 00000020a76cf480 00007fffd4ea1118 KERNELBASE!WaitForSingleObjectEx+0x94, calling ntdll!NtWaitForSingleObject 00000020a76cf520 00007fffce50ce66 clr!CLRSemaphore::Wait+0x8a, calling kernel32!WaitForSingleObjectEx 00000020a76cf5e0 00007fffce50d247 clr!ThreadpoolMgr::UnfairSemaphore::Wait

android app crashes when exceeded Thread pool 9 and queued tasks 128

那年仲夏 提交于 2020-01-02 16:15:13
问题 The application conduction api calls in every 10seconds with the gps location from the network provider. And also there are several api calls can be do by the user. application is crashing with law internet or less internet connection(device data access) is there a proper way to prevent app crashing and hold the api request till the internet network available. here im posting my crash reprort stacktrace java.util.concurrent.RejectedExecutionException: Task android.os.AsyncTask$3@4206a5b0

android app crashes when exceeded Thread pool 9 and queued tasks 128

梦想的初衷 提交于 2020-01-02 16:15:11
问题 The application conduction api calls in every 10seconds with the gps location from the network provider. And also there are several api calls can be do by the user. application is crashing with law internet or less internet connection(device data access) is there a proper way to prevent app crashing and hold the api request till the internet network available. here im posting my crash reprort stacktrace java.util.concurrent.RejectedExecutionException: Task android.os.AsyncTask$3@4206a5b0

Java Executors and per-thread (not per-work unit) objects?

假装没事ソ 提交于 2020-01-02 07:47:27
问题 I have a task that would benefit from the Thread Pool design pattern (many small tasks to be performed in parallel). I initially implemented a naive thread pool from scratch, with n Runnables all pulling work units from the same ConcurrentLinkedQueue until the queue is empty, then terminating. I then decided "hey, let's try the Executor in Java, because that is probably better-tested and more reliable than my naively designed system." Problem: in my implementation, each thread persisted until

NetServerEnum create Worker Threads who won't close

别等时光非礼了梦想. 提交于 2020-01-01 19:52:27
问题 While trying to solve a previously asked SO question of mine, I've find that even without my threads, the problem occurs. what I have now , is a really simple single-threaded code , that calls - NetServerEnum() . when returned, it calls NetApiBufferFree() and return from main, which supposed to end the process. at that point, my thread truly ends, but the process won't exit , as there are 4 threads opened (not by me): 1 * ntdll.dll!TplsTimerSet+0x7c0 (stack is at ntdll.dll

Is there an implementation of std::async which uses thread pool?

假装没事ソ 提交于 2020-01-01 19:41:08
问题 The standard function std::async: The template function async runs the function f asynchronously (potentially in a separate thread which may be part of a thread pool) and returns a std::future that will eventually hold the result of that function call. There is two launch polices std::launch::async and std::launch::deferred. In my compiler's ( GCC 6.2 ) standard library impelmentation, the first one always creates a new thread and the second one does lazy evaluation on the calling thread. By

How to download images asynchronously from web server

谁说胖子不能爱 提交于 2020-01-01 16:48:07
问题 My application screen looks similar to the image attached. I have multiple rows and each row has a Bitmap image, title and description field. All the information's are getting fetched from our supporting web-server in the form of XML. Now, I have used observer design pattern, which creates a separate thread for connecting to my remote server over HTTP, downloads and parse the XML. The XML includes the URL for image, title and description for each row. I have tried few approaches so far,

How to download images asynchronously from web server

倾然丶 夕夏残阳落幕 提交于 2020-01-01 16:48:06
问题 My application screen looks similar to the image attached. I have multiple rows and each row has a Bitmap image, title and description field. All the information's are getting fetched from our supporting web-server in the form of XML. Now, I have used observer design pattern, which creates a separate thread for connecting to my remote server over HTTP, downloads and parse the XML. The XML includes the URL for image, title and description for each row. I have tried few approaches so far,

Close foreground thread gracefully on windows service stop

对着背影说爱祢 提交于 2020-01-01 15:05:23
问题 In my windows service I create one "parent" foreground thread that in turn spawns "child" threads using ThreadPool (which means they are background) to execute tasks. What is the best way to close foreground thread gracefully on windows service stop? Here is my current implementation (stripped out of task-specific logic): public partial class TaskScheduler : ServiceBase { private static AutoResetEvent _finishedTaskAutoResetEvent = new AutoResetEvent(false); //This flag is used to increase