multithreading

How often does a managed thread switch OS threads?

I understand that managed threads are not guaranteed to run on the same OS thread. If the CLR may switch a managed thread between OS threads, how often does this happen? What influence the frequency? I've got a separate question on how to stop the switching from happening. Second prize for me would be for this to not happen too often (...

A multi-part/threaded downloader via python?

I've seen a few threaded downloaders online, and even a few multi-part downloaders (HTTP). I haven't seen them together as a class/function. If any of you have a class/function lying around, that I can just drop into any of my applications where I need to grab multiple files, I'd be much obliged. If there is there a library/framework ...

Watchdog win service to watch another win service

Hi, I want to make a windows service that monitors another windows service, and make sure that it is working. sometimes the Win Service that I want to watch stay in the memory (appear in task manager, so it is considered a running service, but the fact is that it is doing nothing, it is dead, its timer is not firing for one reason, which...

Callback, specified in QueueUserAPC , does not get called

In my code, I use QueueUserAPC to interrupt the main thread from his current work in order to invoke some callback first before going back to his previous work. std::string buffer; std::tr1::shared_ptr<void> hMainThread; VOID CALLBACK myCallback (ULONG_PTR dwParam) { FILE * f = fopen("somefile", "a"); fprintf(f, "CALLBACK WAS IN...

When the property is getted in a ForEach loop?

Hello, I have a property getter with a lock like this one: Public ReadOnly Property ActiveClientList() as List(Of TcpClient) Get SyncLock(m_activeClientListLock) Return m_activeClientList End SyncLock End Get End Property When I do a ForEach loop when is the property getted? I mean, in this loop wh...

Is there any reason to use threading.Lock over multiprocessing.Lock?

If a software project supports a version of Python that multiprocessing has been backported to, is there any reason to use threading.Lock over multiprocessing.Lock? Would a multiprocessing lock not be thread safe as well? For that matter, is there a reason to use any synchronization primitives from threading that are also in multiproce...

JAVA: How to scale threads according to cpu cores?

Hi everyone, I'm new to this site and glad to be here :). I'm not a good java programmer, it's just my hobby, but I'm eager to know more than average stuff. I want to solve a mathematical problem with multiple threads in java. my math problem can be separated into work units, that I want to have solved in several threads. but I don't ...

How to stop one thread until n threads have completed their work.

Hello, I have an application with one main thread and N worker threads. At some point I need that the main thread waits until all the N threads have completed one section of their work. I normally would use Monitor.Wait() and Monitor.Pulse() but this will prevent the N threads from working at the same time. Any idea on how to do that?...

Android - Loading, please wait

Is there a standard "Loading, please wait" dialog I can use in Android development, when I invoke some AsyncTask (downloading some data from remote service for example)? ...

How to use threads in C on Windows?

What do I need and how can I use threads in C on Windows Vista? Could you please give me a simple code example? ...

webservice upload and progress

Please help me with this one, I'm not sure what the correct, or best approach is. Basically I have a webservice which takes a byte stream, enabling a c# winform application to upload files to the webservice. What I need is for the winform to upload in the background one file at a time (using basic multithread, it tries to upload them a...

Writing an around_each filter in ruby for every method within a block.

I need a method that takes a block, and performs something similar to an around_each filter for every method within the block. For instance: def method_that_takes_block (@threads ||= Array.new) << Thread.new {yield if block.given?} end method_that_takes_a_block do method_one method_two method_three end In this instance I wou...

Multi-Threading - waiting for all threads to be signalled

I have scenarios where I need a main thread to wait until every one of a set of possible more than 64 threads have completed their work, and for that I wrote the following helper utility, (to avoid the 64 waithandle limit on WaitHandle.WaitAll()) public static void WaitAll(WaitHandle[] handles) { if (handles == null) ...

Properties of a PHP Worker Pool for Background Processing with Gearman

Hello, I did some reading about Gearman and i am wondering if it can be used as a worker pool for background processing. I am interested in a PHP worker pool with the following properties: A. Workers should be able to run concurrently That is, i should be able to have a worker pool and i am expecting gearman to dispatch multiple work...

performance counter events associated with false sharing

hi I am looking at the performance of OpenMP program, specifically cache and memory performance. I have found guidelines while back ago how to analyze performance with Vtune that mentioned which counters to watch out for. However now cannot seem to find the manual. If you know which manual I have in question or if you know the counters...

Throw event in the main thread from worker thread C# CF

I have, what probably is, a simple problem. I'm using interop to call an asynchronous function in CompactFramework. After I get result of the execution, I would like to raise an event, that will be caught by the form, and based on the results, I would render some data on the screen. The problem, however, is that when interop function ret...

is javascript multithreading possible with IFRAMEs

Hi All, I'm currently playing with the idea of using IFRAMEs to implement a very simple multithreading engine. However my initial results are showing me that running in threads is slower than just running in a single thread. My test is: Single Thread var start = new Date().getTime(); for (var i = 0; i < 300; i++) { /* Do costly proc...

SimpleHTTPServer, shoutdown and blocked request handlers

I have an instance of SimpleHTTPServer, however when I try to call "shutdown" on it and there is a request handler that is blocked - the whole process will block. It does so even if I run the "serve_forever" method in a deamon thread. See example code at http://codepad.org/cn8EYdfg Any advice? ...

Seeking help with a MT design pattern

I have a queue of 1000 work items and a n-proc machine (assume n = 4).The main thread spawns n (=4) worker threads at a time ( 25 outer iterations) and waits for all threads to complete before processing the next n (=4) items until the entire queue is processed for(i= 0 to queue.Length / numprocs) for(j= 0 to numprocs) ...

TcpClient and StreamReader blocks on Read

Here's my situation: I'm writing a chat client to connect to a chat server. I create the connection using a TcpClient and get a NetworkStream object from it. I use a StreamReader and StreamWriter to read and write data back and forth. Here's what my read looks like: public string Read() { StringBuilder sb = new StringBuilder(); try...