threadpool

Is ThreadPool appropriate for this threading scenario?

扶醉桌前 提交于 2020-01-01 11:46:12
问题 I have a scenario that I'm trying to turn into a more responsive UI by pre-fetching some sub-elements of the results before they're actually required by the user if possible. I'm unclear on how best to approach the threading, so I'm hoping someone can provide some advice. Scenario There is search form (.NET rich client) that enable the user to select an account for a given customer. The user searches for given text to find a collection of customers which are then displayed in a result grid.

How to know if all the Thread Pool's thread are already done with its tasks?

人盡茶涼 提交于 2020-01-01 05:04:21
问题 I have this application that will recurse all folders in a given directory and look for PDF. If a PDF file is found, the application will count its pages using ITextSharp. I did this by using a thread to recursively scan all the folders for pdf, then if then PDF is found, this will be queued to the thread pool. The code looks like this: //spawn a thread to handle the processing of pdf on each folder. var th = new Thread(() => { pdfDirectories = Directory.GetDirectories(pdfPath); processDir

Migrate a single threaded app to multi-threaded, parallel execution, monte carlo simulation

若如初见. 提交于 2020-01-01 04:54:09
问题 I've been tasked with taking an existing single threaded monte carlo simulation and optimising it. This is a c# console app, no db access it loads data once from a csv file and writes it out at the end, so it's pretty much just CPU bound , also only uses about 50mb of memory. I've run it through Jetbrains dotTrace profiler. Of total execution time about 30% is generating uniform random numbers, 24% translating uniform random numbers to normally distributed random numbers. The basic algorithm

.NET Custom Threadpool with separate instances

不问归期 提交于 2020-01-01 04:34:09
问题 What is the most recommended .NET custom threadpool that can have separate instances i.e more than one threadpool per application? I need an unlimited queue size (building a crawler), and need to run a separate threadpool in parallel for each site I am crawling. Edit : I need to mine these sites for information as fast as possible, using a separate threadpool for each site would give me the ability to control the number of threads working on each site at any given time. (no more than 2-3)

Java - relationship between threads and CPUs

时光毁灭记忆、已成空白 提交于 2020-01-01 02:29:09
问题 I am pretty new to multithreading, and I am working on a project where I am trying to utilize 4 CPUs in my Java program. I wanted to do something like int numProcessors = Runtime.getRuntime().availableProcessors(); ExecutorService e = Executors.newFixedThreadPool(numProcessors); Will this guarantee that I will have one thread working per CPU? At the time that I create the threads, the system will not be busy, however some time afterwards it will be extremely busy. I thought that the OS will

Not much difference between ASP.NET Core sync and async controller actions

会有一股神秘感。 提交于 2019-12-31 07:56:46
问题 I wrote a couple of action methods in a controller to test the difference between sync and async controller actions in ASP.NET core: [Route("api/syncvasync")] public class SyncVAsyncController : Controller { [HttpGet("sync")] public IActionResult SyncGet() { Task.Delay(200).Wait(); return Ok(new { }); } [HttpGet("async")] public async Task<IActionResult> AsyncGet() { await Task.Delay(200); return Ok(new { }); } } I then load tested the sync end point: ... followed by the async end point: Here

What change did really happen in Async Task after Android Gingerbread?

廉价感情. 提交于 2019-12-31 03:32:08
问题 What change did really Android team make in Async task after android 2.3. When I executed the following code I am getting same result in both Android 2.3 and 3.0. package com.sample.asynctask; import android.app.Activity; import android.os.AsyncTask; import android.os.Bundle; import android.util.Log; public class AsyncTaskTestActivity extends Activity { private static final String TAG = "AsyncTaskTestActivity"; /** Called when the activity is first created. */ @Override public void onCreate

ExecutorService which runs tasks in calling thread?

若如初见. 提交于 2019-12-30 22:55:52
问题 Are there any java.util.ExecutorService implementations which simply run all executed tasks in the calling thread? If this isn't included in Java by default, is there a library which contains an implementation like this? 回答1: The only existing implementation I could find is SynchronousExecutorService - unfortunately buried somewhere in camel library. Pasting source code (without comments) here for future reference: package org.apache.camel.util.concurrent; import java.util.List; import java

Simple thread pool in C++

痞子三分冷 提交于 2019-12-30 10:44:13
问题 Could anyone point me to a sample implementation of a thread pool in C++, please? I'm looking for a very basic one without too much complexity, which would be suitable for a beginner in threading to study. 回答1: Look at Intel's Thread Building Blocks. I don't know how well that library meets your "simple" criteria, but it seems to be very well thought-out and thorough. I would think that it would be worth the effort to learn if you want to do threading in C++. Boost also has some threading

Number of active tasks using ThreadPoolExecutor

落花浮王杯 提交于 2019-12-30 06:45:55
问题 I am using a ThreadPoolExecutor to execute tasks in my Java application. I have a requirement where I want to get the number of active tasks in the queue at any point in time in the executor queue . I looked up at the javadoc for ThreadPoolExecutor and found two relevant methods: getTaskCount() and getCompletedTaskCount() . Per the documentation, I could get the number of scheduled tasks and completed tasks from the above two methods respectively. But I am not able to find a solution for