multithreading

How to get the name of a Win32 Thread?

这一生的挚爱 提交于 2020-01-29 04:32:45
问题 I know of the non-intuitive process to set the name of a thread under Windows (see "How to set name to a Win32 Thread?"). Is there a way to get the name of the thread? I don't see any Windows API that lets me do this (http://msdn.microsoft.com/en-us/library/windows/desktop/ms684847(v=vs.85).aspx). 回答1: There is no such WinAPI call since there exists no such thing as thread names. If you set a thread name then the debugger of your IDE will store it for you, which makes it easier to debug.

Limit Threads count

六眼飞鱼酱① 提交于 2020-01-29 04:02:05
问题 I have a List with items that I want to download. I use a for Loop to iterate the list. For each item in this List I start a new Thread that references the item. My Problem is that I want limit the maxDownload at the same time. for (int i = downloadList.Count - 1; i >= 0; i--) { downloadItem item = downloadList[i]; if (item.Status != 1 && item.Status != 2) { ThreadStart starter = delegate { this.DownloadItem(ref item); }; Thread t = new Thread(starter); t.IsBackground = true; t.Name = item

What's the difference between a worker thread and an I/O thread?

北战南征 提交于 2020-01-28 19:49:31
问题 Looking at the processmodel element in the Web.Config there are two attributes. maxWorkerThreads="25" maxIoThreads="25" What is the difference between worker threads and I/O threads? 回答1: Fundamentally not a lot, it's all about how ASP.NET and IIS allocate I/O wait objects and manage the contention and latency of communicating over the network and transferring data. I/O threads are set aside as such because they will be doing I/O (as the name implies) and may have to wait for "long" periods

What's the difference between a worker thread and an I/O thread?

≯℡__Kan透↙ 提交于 2020-01-28 19:49:06
问题 Looking at the processmodel element in the Web.Config there are two attributes. maxWorkerThreads="25" maxIoThreads="25" What is the difference between worker threads and I/O threads? 回答1: Fundamentally not a lot, it's all about how ASP.NET and IIS allocate I/O wait objects and manage the contention and latency of communicating over the network and transferring data. I/O threads are set aside as such because they will be doing I/O (as the name implies) and may have to wait for "long" periods

How to compile Boost multithreaded program?

不羁的心 提交于 2020-01-28 10:55:13
问题 I installed boost library. Everything is going OK without multithreading. How do i compile this test program ? #include <boost/thread/thread.hpp> #include <iostream> using namespace std; void hello_world() { cout << "I'm new thread!" << endl; } int main(int argc, char* argv[]) { boost::thread my_thread(&hello_world); my_thread.join(); return 0; } I used: g++ -I/home/user/boost/include testc.cpp but g++ show me: /tmp/ccQtBeSf.o: In function `main': testc.cpp:(.text+0x5a): undefined reference

Scheduled executor: poll for result at fix rate and exit if timeout or result valid

僤鯓⒐⒋嵵緔 提交于 2020-01-28 10:54:06
问题 Problem: I have a requirement to call a dao method at fix rate say every 10 sec, then I need to check if the result is valid if yes exit, else keep on calling that method every 10 sec till I get a valid result or defined time out (say 2 min) is over. Approaches: I want to keep the task and scheduler logic separate, and write a task in such a way that it can be used by different classes having similar requirement. One way I can think is to define a new poller task public abstract class

Is it possible to 'thread' Javascript and keep access to the UI?

一个人想着一个人 提交于 2020-01-27 08:22:07
问题 I would like to thread some Javascript code while both the main process and thread are free to update the browser UI. For example: function StartStuff() { StartThreadedCode(); // do more work and update the UI while StartThreadedCode() does its work } function StartThreadedCode() { // do stuff (do work and update the UI) } Is it possible? 回答1: There are two main ways to achieve "multithreading" in Javascript. The first way is a cross-browser solution, that would also work in older browsers,

How to know who kills my threads

蹲街弑〆低调 提交于 2020-01-27 05:26:25
问题 I got a thread that is just banishing.. i'd like to know who is killing my thread and why. It occurs to me my thread is being killed by the OS, but i'd like to confirm this and if possible to know why it's killing it. As for the thread, i can assert it has at least 40 min of execution before dying, but it suddenly dies around 5 min. public void RunWorker() { Thread worker = new Thread(delegate() { try { DoSomethingForALongLongTime(); } catch(Exception e) { //Nothing is never logged :(

How to know who kills my threads

|▌冷眼眸甩不掉的悲伤 提交于 2020-01-27 05:26:08
问题 I got a thread that is just banishing.. i'd like to know who is killing my thread and why. It occurs to me my thread is being killed by the OS, but i'd like to confirm this and if possible to know why it's killing it. As for the thread, i can assert it has at least 40 min of execution before dying, but it suddenly dies around 5 min. public void RunWorker() { Thread worker = new Thread(delegate() { try { DoSomethingForALongLongTime(); } catch(Exception e) { //Nothing is never logged :(

How do I specify the equivalent of volatile in VB.net?

烂漫一生 提交于 2020-01-27 04:18:13
问题 I'm attempting to write a lock-free version of a call queue I use for message passing. This is not for anything serious, just to learn about threading. I'm relatively sure my code is correct, except if the instructions are re-ordered or done in registers. I know I can use memory barriers to stop re-ordering, but how can I ensure values are written to memory immediately? Public Class CallQueue Private first As New Node(Nothing) 'owned by consumer' Private last As Node = first 'owned by