threadpool

Long-running background process in ASP.NET - Application_Start or separate process?

自闭症网瘾萝莉.ら 提交于 2019-11-27 06:05:27
问题 I'm developing a .NET 4 application that requires a backend worker thread to be running. This thread consists mostly of the following code: while (true) { //Check stuff in database //Do stuff //write to database / filesystem Thread.sleep(60000) } The ASP.NET app is just a frontend for the database. My question is around where the best place to put this worker loop would be. It seems my immediate two choices would be (1) to spin it off from the Application_Start method, and just let it run, or

Java: ExecutorService that blocks on submission after a certain queue size

心已入冬 提交于 2019-11-27 06:01:39
I am trying to code a solution in which a single thread produces I/O-intensive tasks that can be performed in parallel. Each task have significant in-memory data. So I want to be able limit the number of tasks that are pending at a moment. If I create ThreadPoolExecutor like this: ThreadPoolExecutor executor = new ThreadPoolExecutor(numWorkerThreads, numWorkerThreads, 0L, TimeUnit.MILLISECONDS, new LinkedBlockingQueue<Runnable>(maxQueue)); Then the executor.submit(callable) throws RejectedExecutionException when the queue fills up and all the threads are already busy. What can I do to make

Should i use ThreadPools or Task Parallel Library for IO-bound operations

独自空忆成欢 提交于 2019-11-27 05:59:24
In one of my projects that's kinda an aggregator, I parse feeds, podcasts and so from the web. If I use sequential approach, given that a large number of resources, it takes quite a time to process all of them (because of network issues and similar stuff); foreach(feed in feeds) { read_from_web(feed) parse(feed) } So I want to implement concurrency and couldn't decide if I should basically use ThreadPools to process with worker threads or just rely on TPL to get it sorted. ThreadPools for sure will handle the job for me with worker threads and I'll get what I expect (and in multi-core CPU

Why we need a connection pooling for JDBC? [closed]

吃可爱长大的小学妹 提交于 2019-11-27 05:40:34
问题 What are the benefits of using a JDBC connection pooling tool like DBCP or c3p0 ? in case of a small CRUD application with one user, can we just create one connection session as a singleton ? PS : I'm building a small javafx application back-ended with tiny h2 database (5 tables). 回答1: From Jon Skeet's answer to What is the benefit of Connection and Statement Pooling?: Creating a network connection to a database server is (relatively) expensive. Likewise asking the server to prepare a SQL

What is the meaning of thread-agility in ASP.Net?

余生颓废 提交于 2019-11-27 05:08:35
I am reading an article about HttpContext and CallContext and see thread-agility. What does it mean? It means that IIS is free to use more than one thread to handle a single request, although not in parallel. Basically, IIS tries to perform I/O operations asynchronously, thus freeing the calling thread for the duration of the operation. That thread is returned to the pool and can be used to handle other requests in the meantime. When the asynchronous I/O operation completes, control can be returned to a thread other than the one that originally handled the request (since that thread can be

Python Postgres psycopg2 ThreadedConnectionPool exhausted

只谈情不闲聊 提交于 2019-11-27 04:56:40
I have looked into several 'too many clients' related topic here but still can't solve my problem, so I have to ask this again, for me specific case. Basically, I set up my local Postgres server and need to do tens of thousands of queries, so I used the Python psycopg2package. Here are my codes: import psycopg2 import pandas as pd import numpy as np from flashtext import KeywordProcessor from psycopg2.pool import ThreadedConnectionPool from concurrent.futures import ThreadPoolExecutor df = pd.DataFrame({'S':['California', 'Ohio', 'Texas'], 'T':['Dispatcher', 'Zookeeper', 'Mechanics']}) # df =

TaskCreationOptions.LongRunning option and ThreadPool

天涯浪子 提交于 2019-11-27 04:23:19
TPL uses Task Schedulers to coordinate tasks. According to official document , default task scheduler uses Thread Pool, but if TaskCreationOptions.LongRunning option is presented then it will create a dedicated thread for that task (A). Question: As of now MSDN documents for Visual Studio 2010 are not ready and current online MSDN is not finalized; does anyone knows if (A) is true or false? Yes, LongRunning forces the creation of a new thread outside the pool. Here's some pseudo-disassembled code from the latest framework version: ... if (task.Options HasFlag LongRunning) then create new

How to wait for thread to complete without blocking UI

早过忘川 提交于 2019-11-27 04:21:20
问题 I want my program to wait after below line frmProgressBarObj = PullMSI.ExtractByMSIName("products.txt", false); as above method is internally calling thread through StartProcessWithProgress() method . I want that thread to be completed before //code logic -2 line gets executed. At the same time, It should not stop UI update done by frmProgressBar.UpdateProgress(). How do I do this? namespace NS1 { public partial class frmMain : Form { private void button1_Click(object sender, EventArgs e) {

How Threadpool re-use Threads and how it works

人走茶凉 提交于 2019-11-27 03:55:34
My Multithreading concepts are weak and trying to learn. In java what i know is, we can't call a Thread more then once i.e Thread t = new Thread(//Some Runnable); t.start() t.start() //Illegal and throw Exception at Runtime. As far as I know, it throws exception when you call t.start() again because the associated stack for the Thread is destroyed once it goes out of run() method and you are trying to initialize things again. In that case, what I know about Threadpool is, it gives Better performance & saves time because there is no need to create new thread. (I read in http://www.javatpoint

Will values in my ThreadStatic variables still be there when cycled via ThreadPool?

余生长醉 提交于 2019-11-27 03:55:21
问题 I am using ThreadStatic variables to store some data, but I am worried that the data I store on the thread will still be there after I am finished with it and release back to the ThreadPool. Do I need to worry about clearing my ThreadStatic variables before I am finished with the thread? Or will the ThreadPool do this for me before "passing it out" for the next QueueUserWorkItem? This is especially important for me because I need to make sure that other threads in my app have a clean slate to