multithreading

Java threading question - listening to n error streams

Hello all, Let me say first that my experience with threading is pretty low. I have an app that starts up several other Java jars via the Runtime.exec method. The problem is that the jars that are started need to be run concurrently, but in order to get at the error stream for the started jars you have to basically have a loop 'sitti...

.NET or Windows Synchronization Primitives Performance Specifications

Hello *, I am currently writing a scientific article, where I need to be very exact with citation. Can someone point me to either MSDN, MSDN article, some published article source or a book, where I can find performance comparison of Windows or .NET Synchronization primitives. I know that these are in the descending performance order: ...

What real-life analogies do you use when explaining threading related problems to co-workers?

It seems that often it is better to use real-life analogies to explain some things. But I can't find a single all-encompassing analogy to talk about all things multithreaded. Sometimes I use the room and the locking door analogy, but it doesn't explain deadlocking very easily. The flashcards and TV-watching paradigms are even more lim...

Objective-C equivalent of Java's BlockingQueue?

I'm just getting into iPhone development after many years doing Java development. I'm looking for the Objective-C equivalent to Java's BlockingQueue. Is there something like that? In case I'm going about things the wrong way, here's what I'm trying to achieve: I want to display, one at a time, chunks of data pulled from a network serve...

Get running threads information in an Application

I'm developing desktop application, where I upload series of FPGA files on scanning device, to do this job I have COM DLL provided by driver. For uploading files I call method named "StartWrite", which start worker thread to write FPGA to device. And now in C# how do I get list/information (expected execution time etc.) of worker thre...

API for allocating threds to cores

In general the operating system takes care of allocating threads to cores. I wonder whether there is a way for the program to be invloved in this allocation. In other words: Is there an API (for either the Linux or Win32 platforms) enabling to create a thread that is associated with a specific core? ...

Unresponsive thread in Tomcat

Env: Tomcat 5.x on Java 1.5.x on Windows using OracleJDBC driver on Oracle 9i The problem: I have a thread which is in RUNNABLE state. It doesn't seem to complete -ever. How do I investigate this further ? This is reproducible quite easily. This thread is basically trying to insert some data Update: This insert is happening in a syn...

How to detect which mutex gives largest amount of time to the OS?

How to measure amount of time given by a mutex to the OS? The main goal is to detect a mutex, that blocks threads for largest amount of time. PS: I tried oprofile. It reports 30% of time spent inside vmlinux/.poll_idle. This is unexpected, because the app is designed to take 100% of its core. Therefore, I'm suspecting, that the time is ...

What is the optimal number of threads for performing IO operations in java?

In Goetz's "Java Concurrency in Practice", in a footnote on page 101, he writes "For computational problems like this that do not I/O and access no shared data, Ncpu or Ncpu+1 threads yield optimal throughput; more threads do not help, and may in fact degrade performance..." My question is, when performing I/O operations such as file wr...

C# Threading Performance, One Thread 99% Of The Time

I have a multi-threaded C# application. There is one dictionary that is accessed from N different threads at the same time. 99% of the calls are from thread A and the rest are from B, C, ... Right now, I'm just locking the dictionary on each access. But it seems wasteful because 99% of the time that I'm calling lock, thread A already...

Multiple threads in Java causing problems.

Sorry for another vague example...but I have a single class where I'm starting a new thread instance. However, if I add a new thread instance, it interrupts (destroys?) the first. But, if I run two instances of the class (separately, after I turn them into jar files) where each instance only opens up a single thread, they both run concu...

BackgroundWorker thread and Timer logic

I've been trying to get the logic right for my timer and backgroundworker thread. Granted I don't fully understand the whole system despite all my reading. the following are excerpts of code concerned: My polling button : private void pollStart_Click(object sender, EventArgs e) { tst_bgw = new BackgroundWorker(); //...

Threading problem with Visual Studio Debugger.

Hey fellas. I have an application that is designed to be run across a network. This means that the initial run of this application can take a while. So I've been putting together a splash screen to pretty the process up some. It uses threading to show the form via a static method. I'm still something of a threading novice, so when I go...

Correctly destroying named System V semaphores

I'm using named System V semaphores to lock a file across all my apps on OSX and linux. Not prettiest of APIs by any definition. It seems to work, but I can't quite figure out how to properly destroy the semaphore after everybody is done with it. General logic is like this: Creating: [1] Thread or process tries to open a semaphore se...

My GUI is frozen

Hi all, I have something I can't understand: my Swing GUI contains a 'play' and 'pause' button. I have also a static variable that defines 'ON' and 'OFF' states. (The main program generates the GUI). By cliking on 'play' I change the state of my static variable to 'ON' and I launch a time-consuming process in a thread that also modifies...

Which Java blocking queue is best for multiple producer and single or multiple consumers scenarios?

Which Java blocking queue is best for multiple producer and single or multiple consumers scenarios ? I am testing with LinkedBlockingQueue but i am getting OutOfMemoryError exception. I am trying to achieve following things. producer creates a object & put in a queue. consumer grabs the data from queue & insert into DB. There woul...

Threading nested foreach-loops?

Helllo! I'm trying to build a program that calculates the best score from a various amount of items with bruteforce. And I believe that the speed to calculate this can be improved on systems with multicore CPUs with the help of threading. Correct me if I'm wrong. But how do I achieve this? Here's a part of my code, and it does the job ...

Using threads and ProcessBuilder

I am really unfamiliar with working with threads, so I was hoping someone could help me figure out the best way to do this. I have a JButton in my java application...when you click on the button, I have a Process Builder that creates a process which executes some external python code. The python code generates some files, and this can t...

Which methods can be used to make thread wait for an event and then continue its execution?

I have a thread running that delegates out some tasks. When a single task is complete, an event is raised saying that it has completed. These tasks need to be run in a specific order and need to wait for the previous task to finish. How can I make the thread wait until it receives the "task completed" event? (Aside from the obvious event...

How do I control memory usage with Omni Thread Library's thread pool?

I've been using gabr's OmniThreadLibrary to build a ThreadPool. I'm a novice when it comes to multi-threading, which is why I've found OTL to be so interesting. Following the demo application "app_11_ThreadPool.exe", I setup a thread pool in my application. The purpose of my app is to take a list of URL's, and attempt to connect to the...