multithreading

How to solve these problems with Asynchronous Callback>

I need to run 5 algorithms parallely each takes an image as input and gives image as output. After each of these is done, I need to display the 5 output images. I'm using Asynchronous Callback using delegates for this task. So, I created 5 delegates for these 5 algos and calling them like algo1Delegate.BeginInvoke(). Algorithms are run...

is pwrite after dup race safe?

On Linux pwrite operation (which is seek+write) is atomic, meaning doing pwrite-s in multiple threads with one file descriptor is safe. I want to create file descriptor duplicate, using dup(). Now, having fd1 and fd2 - will pwrite-s work as expected, or there's danger of race condition? ...

Why is the TaskFactory.StartNew method not generic?

The idomatic way to start a new side-effect-only task (that is: a task that returns no result) using the TPL in .NET 4.0 is using the following API: Task Task.Factory.StartNew(Action<object>, object) But why doesn't the signature of this API look like this Task Task.Factory.StartNew<T>(Action<T>, T) or like this Task Task.Factor...

synchronizing access to common data

I have a WinForms app (c#) that has a background thread that periodically grabs data from a data source, does some manipulation of it, and puts it in a DataTable. There are 1 or more components in the app that periodically poll this common data to do stuff with it. I'm wondering, what's the "right" way to synchronize this, so e.g. the co...

How can catched exception be null (not NullReferenceException)?

Hey I have run into a rather weird little problem. In the following code I can not understand how e can be null; try { //Some Code here } catch (Exception e) { //Here e is null } As far as I know, throw null will be converted to throw new NullReferenceException(). The problem seems to be related to multithreading, as removi...

Traversing a Binary Tree with multiple threads

So I'm working on a speed contest in Java. I have (number of processors) threads doing work, and they all need to add to a B-Tree. Originally I just used a synchronized add method, but I wanted to make it so threads could follow each other through the tree (each thread only has the lock on the object it's accessing). Unfortunately, even ...

Is synchronized needed here

I have a java applet. A class inside that applet is creating a thread to do some work, waiting 30 seconds for that work to complete, if its not completed in 30 secs it sets a Boolean to stop the thread. The wait and Boolean change are in a synchronized block, Is this necessary considering there is no other thread running aside from these...

Ruby threading deadlocks

I'm writing a project at the moment that involves running two parallel threads to pull data from different sources at regular intervals. I am using the Threads functionality in ruby 1.9 to do this but am unfortunately running up against deadlock problems. Also I have a feeling that the Thread.join method is causing the threads to queue r...

Show progress in dialog

i have a process ta take long time and i want a window to show the progresse but i can't figure how to display the progress here the code: if (procced) { // the wpf windows : myLectureFichierEnCour = new LectureFichierEnCour(_myTandemLTEclass); myLectureFichierEnCour.Show(); ...

Execute a task after the modelAndView is returned

In Spring, is there a way to execute a task after returning a view or I need to create a ThreadPool and do it ? Ex: public ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response) throws Exception { Map<Object, Object> data = new HashMap<Object, Object>(); //do some stuff exe...

std::list threading push_back, front, pop_front

Is std::list thread safe? I'm assuming its not so I added my own synchronization mechanisms (I think i have the right term). But I am still running into problems Each function is called by a separate thread. Thread1 can not wait, it has to be as fast as possible std::list<CFoo> g_buffer; bool g_buffer_lock; void thread1( CFoo fram...

gdb backtrace and pthread_cond_wait()

This is on a Redhat EL5 machine w/ a 2.6.18-164.2.1.el5 x86_64 kernel using gcc 4.1.2 and gdb 7.0. When I run my application with gdb and break in while it's running, several of my threads show the following call stack when I do a backtrace: #0 0x000000000051d7da in pthread_cond_wait () #1 0x0000000100000000 in ?? () #2 0x0000000000...

Is LWP::UserAgent not thread-safe?

I'm running 40-or-so threads with the following subroutine: my $app = shift; my $ua = LWP::UserAgent->new(); $ua->timeout(5); my $response = $ua->get($$app{'watch_url'}); my $new_md5; if ($response->is_success()) { $new_md5 = md5_hex($response->content()); } return ($$app{'short_name'}, $$app{'watch_md5'}, $new_md5); Core dumps en...

Effects of calling SetThreadUILanguage

What are the effects of calling SetThreadUILanguage in an applicaton? Will it cause captions like "OK" and "CANCEL" on a MessageBox to appear in the language set through this API? If the captions do appear in the set language, do they require a localized version of the OS in that language or is it sufficient to have an MUI (Multilinguis...

Collecting Return Values from Launched Threads? [latest Java]

I'm looking for the simplest, most straightforward way to implement the following: main starts and launches 3 threads all 3 tasks process and end in a resulting value (which I need to return somehow?) main waits (.join?) on each thread to ensure they have all 3 completed their task main somehow gets the value from each thread (3 values...

android UI thread

How can I know if the running code is executed in the main thread (UI thread). With Swing I use the isEventDispatchThread method... ...

Apache with JBOSS using AJP (mod_jk) giving spikes in thread count.

We used Apache with JBOSS for hosting our Application, but we found some issues related to thread handling of mod_jk. Our website comes under low traffic websites and has maximum 200-300 concurrent users during our website's peak activity time. As the traffic grows (not in terms of concurrent users, but in terms of cumulative requests ...

Thread safety of std::map for read-only operations.

I have a std::map that I use to map values (field ID's) to a human readable string. This map is initialised once when my program starts before any other threads are started, and after that it is never modified again. Right now, I give every thread its own copy of this (rather large) map but this is obviously inefficient use of memory and...

ActiveX control cannot be instantiated because the current thread is not in a single-threaded apartment.

As the subject is self explainatory, I need help. I'm writing a small tool that displays a splash screen when starting. The splash screen is a Form. When there was only a Button control on it it was working fine. But when I removed it and placed a WebBrowser control on it, it throws the above exception. Thanks in advance. ...

Multiple instances of QWebView (qt jambi)

Good day, How I can use QWebView with method load() in threads? I have create QWebView in main(!) thread, but I can't use load() with QWebView (used signals/slots from other threads to do it): QWebView wv = new QWebView(); //ok QUrl url = new QUrl("http://somesite.com/"); //ok wv.load(url); //ERROR: QObject: Cannot create children for...