threadpool

Android AsyncTask not being called for minutes on ICS

ε祈祈猫儿з 提交于 2019-12-10 17:23:48
问题 I have an application that uses a lot of AsyncTasks, the problem I have is that a particularly important task is not being started for upto a couple of minutes after I call execute. If I use the following for my ICS devices it works; if(Build.VERSION.SDK_INT >= 11) { myTask.executeOnExecutor( AsyncTask.THREAD_POOL_EXECUTOR, stuff ); } as opposed to this on pre-ICS; myTask.execute(stuff); I am aware that ICS has changed thread execution to be serialised but I can't figure out what is holding

ThreadPool.SetMinThreads doesn't work in IIS hosted application

Deadly 提交于 2019-12-10 17:17:33
问题 I have ASP.NET 4.6 application that is designed as Web API. It has one long running operation that takes about 60 seconds, but this operation isn't heavily loaded, let's imaging that like Thread.Sleep(60000) . This operation cannot be asynchronous at the moment because it depends on third party non-async library, therefore it blocks a thread executing this operation for 60 seconds. The problem becomes when more than 50 requests are sent to the application at the same moment, new requests are

Safely Destroying a Thread Pool

我们两清 提交于 2019-12-10 15:37:29
问题 Consider the following implementation of a trivial thread pool written in C++14. threadpool.h threadpool.cpp Observe that each thread is sleeping until it's been notified to awaken -- or some spurious wake up call -- and the following predicate evaluates to true : std::unique_lock<mutex> lock(this->instance_mutex_); this->cond_handle_task_.wait(lock, [this] { return (this->destroy_ || !this->tasks_.empty()); }); Furthermore, observe that a ThreadPool object uses the data member destroy_ to

Java “Tiered Queue” implementation for fast Producers, slow Consumers

[亡魂溺海] 提交于 2019-12-10 14:58:20
问题 I have a producer-consumer scenario where the producers produce much faster than the consumers can consume. Generally, the solution is to make the producers block since a producer/consumer scenario operates as fast as the slowest component. Throttling or blocking the producers is not a good solution because our application provides enough time for consumers to catch up later. Here's a diagram depicting a full "phase" in our application vs. a more common scenario: Our Application Common

newFixedThreadPool.setCorePoolSize() doesn't make use of the threads, creates new theads which may be overhead

人走茶凉 提交于 2019-12-10 14:42:30
问题 newFixedThreadPool.setCorePoolSize() doesn't make use of the threads, creates new theads. Explanation: I make a newFixedThreadPool for size 2 and if both the threads of this pool are busy I add two more threads to this pool using setCorePoolSize(). In this process it doesn't seem to reuse the threads or may be terminating some threads and creating new which I will explain with code. Code: (Please also see the Output for understanding) public class IncreasePoolSize { static ExecutorService

Does a single web request to IIS stay on a single thread?

混江龙づ霸主 提交于 2019-12-10 14:29:05
问题 I want to write a logging http module that stores a list of log events for a single request in thread local storage while the request executes. On End_Request I want to write all the events back to persistent storage. Question is, will one request match to one thread? I.e. can I assume from anywhere in my code that I can add items to the IEnumerable and they will properly be all together at the end of the request. 回答1: No. ASP.NET can potentially switch threads while processing a request.

Threading Library for Multithreaded Windows Service [closed]

☆樱花仙子☆ 提交于 2019-12-10 13:41:21
问题 As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance. Closed 6 years ago . I'm looking for a good library, preferably in C#, which I can use in a windows service and it will handle all the multithreading

Correct way of checking when ThreadPool threads are done?

跟風遠走 提交于 2019-12-10 12:17:19
问题 I'm looking for a way of checking when all threads in threadpool have finished their tasks. Currently I'm using a counter that decrements when a thread has finished it's job and when counter == 0 I'm invoking my WorkComplete method. This seems to work but when i get to the final 'job' it doesn't appear to process the result? Or at least the UI doesn't get it. Here is what i currently have: Queuing work items + incrementing counter foreach (string s in URLs) { ThreadPool.QueueUserWorkItem(new

JMS and ThreadPool problem?

我只是一个虾纸丫 提交于 2019-12-10 12:05:17
问题 I want that jms receives a message when one thread has handled a message (threadPool submits a callable). The messages are received by a master thread. Which way is better below: I use spring 3.0.5 : ApplicationContext context = new ClassPathXmlApplicationContext( "application-context.xml"); jmsTemplate = (JmsTemplate) context.getBean("jmsTemplate"); destination = (Destination) context.getBean("destination"); _log4j.debug("ThreadSize in xml\t" + appConfig.getThumbCreatorThreadSize()); in

scala Future processing depth-first not breadth-first

南楼画角 提交于 2019-12-10 12:05:13
问题 I have a large computation roughly based on the following pattern : def f1(i:Int):Int = ??? def f2(i:Int):Int = ??? def processA(l: List[Int]) = l.map(i => Future(f1(i))) def processB(l: List[Int]) = { val p = processA(l) p.map(fut => fut.map(f2)) } def main() = { val items = List( /* 1k to 10k items here */ ) val results = processB(items) results.map(_.onComplete ( ... )) } The problem I encounter, if my understanding is correct, is that the processing is breadth-first. ProcessA starts