multithreading

Conditional wait overhead

When using boost::conditional_variable, ACE_Conditional or directly pthread_cond_wait, is there any overhead for the waiting itself? These are more specific issues that trouble be: After the waiting thread is unscheduled, will it be scheduled back before the wait expires and then unscheduled again or it will stay unscheduled until sign...

How do I know what shared variables I need to protect with a lock in c++ using boost?

For example, multithreading would never work if mutexes were not resilient to multithreaded access (e.g., two simultaneous calls to mutex.lock() can't screw things up). Does this extend to condition variables too? Specifically, I want to release a lock and then call cond.notify_one(). Theoretically, another thread could then grab the lo...

ManualResetEvent WaitOne(timeout) returns early. Any ideas why?

Hi, I'm using the ManualResetEvent WaitOne(timeout) method and set the timeout value to 30ms. I log using log4net at either side of the WaitOne. The log messages show the WaitOne returned false after only waiting for 22ms. What would cause this? A .Net bug? Thanks in advance. ...

java stress test app with thread pool executor

Well i have the following problem. I want to stress test an application of mine that is deployed on a Tomcat server. The case i want to test is the following: a user uploads a file, the file is transcoded to another format and the new file is downloaded back to a user's device. I simulate every user with a thread(with three operations mo...

Detecting when you're in/out of the main thread in Monotouch

Is there a way in iOS / Monotouch to detect whether code is being called in the main thread? I'm looking for something like the equivalent of Java's EventQueue.isEventDispatchThread() -- I've found in Swing programming it's handy to assert that from time to time (or sometimes to assert that it's not) -- making sure that models are consi...

Java, multiple threads with only one executing at a time

I am working on an assignment and have to create two classes, one represents a person, and the other representing a bridge. Only one person can be "crossing" the bridge at any one time, but there could be people waiting to cross I easily implemented this with multi-threading allowing for multiple people to cross at once, but I am having...

Aborting non working thread

I have I multi thread application written by c#, my max thread number is 256 and this application gets the performance counters of the computers in an Ip interval(192.168.1.0 -192.168.205.255) it works fine and turns many times in a day. because I have to get reports. But the problem is some times one machine keeps a thread and never f...

android: InputConnection from different thread

does commitText() method of android.view.inputmethod.InputConnection allowed to be called from different thread than UI thread? ...

Is it possible to read and write in file at the same time ?

Here's the scenario: ThreadA is going to read from some socket, and write data to "MyFile.txt" ThreadB is going to read "MyFile", and when it reaches the end, it will loops until new data are available in MyFile (because i don't want to re-open "MyFile.txt", and lose the time so i reach the position from where i was..). Is it possibl...

Sending messages to a thread?

I need to imlement in cocoa, a design that relies on multiple threads. I started at the CoreFoundation level - I created a CFMessagePort and attached it to the CFRunLoop, but it was very inconvenient as (unlike on other platforms) it needs to have a (systemwide) unique name, and CFMessagePortSendRequest does not process callbacks back t...

WCF Service and Threading

I have created a simple WCF (.NET 3.5) service which defines 10 contracts which are basically calculations on the supplied data. At the moment I expect quite few clients to make a call to some of these contracts. How do I make the service more responsive ? I have a feeling that the service will wait until it process one request to go to ...

How to Pass a variable to another Thread

using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading; namespace ConsoleApplication1 { class Program { static void Main(string[] args) { Console.WriteLine("Taking data from Main Thread\n->"); string message = Console.ReadLine(); ThreadStart newThrea...

Are there any platforms that do not support reentrent mutex's or recursive locks?

I'm wondering if my implementation should expect that reentrant mutex's are supported or not. The code is supposed to portable/platform independent. I'm wondering if mutex recursion is common enough that it shouldn't be a concern. ...

Cocoa app interface randomly "disconnecting" from program code

I have a multi-threaded Cocoa app that processes images. The program has a progress bar and some text showing how far along the process is. This all works great. However, sometimes the interface will just freeze up and everything will stop updating. The progress bar stops moving, and the text stops updating in the percentage counter. How...

What’s the best way to delete boost::thread object right after its work is complete?

I create boost::thread object with a new operator and continue without waiting this thread to finish its work: void do_work() { // perform some i/o work } boost::thread *thread = new boost::thread(&do_work); I guess, it’s necessary to delete thread when the work is done. What’s the best way to this without explicitly waiting for ...

InvalidOperationException when creating LinearGradientBrush in multi-threaded WPF app

In a static C# method, I do var brush = new LinearGradientBrush(_snazzyGradient);, and this line throws an exception. _snazzyGradient is defined as follows: private static readonly GradientStopCollection _snazzyGradient = new GradientStopCollection { new GradientStop((Color)ColorConverter.ConvertFromString("#DBF3FF"), 0...

Why is cross thread operation exception not thrown while running exe in bin\Debug

I was debugging an application and somewhere in the code, a thread tries to reach a listbox that was created by another thread. On attempt to access the listbox, the application throws a "Cross-thread operation not valid: Control 'listbox' accessed from a thread other than the thread it was created on" exception while debugging. However,...

How to remove deadlock in Java code using NetBeans

I have old code in Java which deadlocks... I never used netbeans as a development tool... however, I need to fix the code. I ran the application in debug mode, clicked on check for deadlock and netBeans brought a screen. Two out of four threads were in red... see the screen dump below. I'm new to multithreading, and on the top of that ...

C# Pause After Bringing Application to Foreground for Input

I have a method that gets called into a new thread like so: if (!_isPlaying) { _playBackThread = new Thread(PlayMacroEvents); _playBackThread.Start(); ... } The method looks like: Process proc = Process.GetProcessesByName("notepad").FirstOrDefault(); if (proc != null) { ...

Thread pool shared resource locking problem

I have a UDP based application that is implemented using a thread pool. Messages are pushed onto a queue and the thread pool is woken when there are things to do or messages on the queue. The thread pool processes each of the messages and hands them off to session objects which hold some state. i.e. the UDP packets are part of a sessio...