multithreading

multithreading: event driven vs message driven

Is there a difference in performance when multi-threading developed with win32 event objects (CreateEvent) or with thread window message queue. Both should use some kind of WaitFor... calls. My own code almost completely based on event, but maybe I lose something when don't use messages. ...

Synchronous Distributed Objects Over NSConnection Issue

I have an application that pulls data from the web, parses them, and compiles the results in a search interface. Since the data are not co-dependant, it made sense to multi-thread the application to execute multiple fetches and parses simultaneously. I use NSInvocationOperation on a search and parse object I have written to execute thi...

Distinguish Java threads and OS threads?

In Production system,like Banking application running in Linux environment, How do I distinguish running Java threads and native threads? In Linux there will be Parent process for every child process, and they say 0 is the parent of all the process, will there be a Parent thread of all the forked Java threads? How do I know which Java ...

C# sharing locks with multithreading

Is there a common way to "share" a lock between different objects operating on same set of data? I am aware that having a public object for locking is usually not recommended. For example, a Queue could be implemented as thread safe, but some other class might need a specific lock in order to lock several Queue operations. What happens...

What's the intended use of _fread_nolock, _fseek_nolock?

Hi there, we have a C++ class which basically reads and writes vectors from a binary file. An exemplary read function that loads a single vector into memory looks like this: int load (const __int64 index, T* values) const { int re = _fseeki64(_file, index * _vectorSize + _offsetData, SEEK_SET); assert(re == 0); size_t read = frea...

WPF multithreaded progress dialog...

Updated This is kind of an interesting problem I am experiencing. I need to have a progress dialog show when a background process is running. Normally, this would work but the problem is that I need to set public static data within the background process. Here is an example of what I am attempting to accomplish: public partial clas...

What's a pattern for getting two "deep" parts of a multi-threaded program talking to each other?

I have this general problem in design, refactoring or "triage": I have an existing multi-threaded C++ application which searches for data using a number of plugin libraries. With the current search interface, a given plugin receives a search string and a pointer to a QList object. Running on a different thread, the plugin goes out and s...

backgroundworker in xbap freezes when published

I have created an xbap front end that brings data from an sql server and displays them. A BackgroundWorker is responsible for this communication, in order for the UI to remain responsive during the query. Everything works as expected on my machine when debugging. Then I publish the project on a network drive, and it still behaves as exp...

How can I pass a multi dimensional array as an argument to a worker thread in C#?

How can I do this in c#? I have GUI and worker threads and I have to pass the array or be able to access the array from worker array?! Thread t = new Thread (delegate() { DoWork (double[,] data); }); t.Start(); static void DoWork (double[,] data) { do some work...; } ...

C++/CLI managed thread cleanup

Hi. I'm writing a managed C++/CLI library wrapper for the MySQL embedded server. The mysql C library requires me to call mysql_thread_init() for every thread that will be using it, and mysql_thread_end() for each thread that exits after using it. Debugging any given VB.Net project I can see at least seven threads; I suppose my library w...

Linux multithreading would involve the pthreads library(in most cases) . What is the equivalent library used by MSVC ?

I need to know which are the APIs/library used for multithreading by MSVC . If there are more than one , please let me know which is the most widely used. If my question sounds too naive , its because I've never done threading before , and from my past experience , I know there are people here who can get me started/point me at the righ...

Can a thread be pre-empted in the midst of a system call to kernel ?

I'm running 2 threads ( assume they are pthreads for the moment) . Thread_1() makes a user-defined API call which ultimately does some work in the kernel . Thread_2() is totally in user-space. My question is : Can Thread_2() start executing by pre-empting Thread_1() while the API call is in progress , the control is somewhere inside th...

Threading security policy

Suppose I'm writing some environment which execute clients code (Java). Clients send jar with manifest information. Environment creates some class instance from jar (suppose instance of Runnable) and run it in some thread. But I need guarantee that clients code will not start own threads or create own ExecutorService and so on. Is there...

Python tempfile module and threads aren't playing nice; what am I doing wrong?

I'm having an interesting problem with threads and the tempfile module in Python. Something doesn't appear to be getting cleaned up until the threads exit, and I'm running against an open file limit. (This is on OS X 10.5.8, Python 2.5.1.) Yet if I sort of replicate what the tempfile module is doing (not all the security checks, but jus...

vs2008 c#: Thread pool question

I am using the following 2 methods. Method called DoMyWork1 does scale well like it takes 6 seconds to run three of them in 3 threads. Whereas DoMyJob method does not scale at all. If one thread takes 4 seconds then it takes 13 seconds to run 3 threads. What am I doing wrong? Does file read and/or write needs special thread handling othe...

Why would you catch InterruptedException to call Thread.currentThread.interrupt()?

In Effective Java (page 275), there is this code segment: ... for (int i = 0; i < concurrency; i++) { executor.execute(new Runnable() { public void run() { ready.countDown(); try { start.await(); action.run(); } catch (InterruptedException e) { Thread.currentThread().interrupt(); } finally { ...

How to ensure Java threads run on different cores

Hello, I am writing a multi-threaded application in Java in order to improve performance over the sequential version. It is a parallel version of the dynamic programming solution to the 0/1 knapsack problem. I have an Intel Core 2 Duo with both Ubuntu and Windows 7 Professional on different partitions. I am running in Ubuntu. My prob...

How do i make the mutex not be recusive?

I ran the code below expecting flow to be locked on the 2nd time i lock a mutex. After running it twice i realize it can lock many times (assuming in the same thread) without stopping. How do i change this behavior? using System; using System.Collections.Generic; using System.Text; using System.Threading; namespace Test { class Pr...

Understanding synchronized

Given this code: public class Messager implements Runnable { public static void main(String[] args) { new Thread(new Messager("Wallace")).start(); new Thread(new Messager("Gromit")).start(); } private String name; public Messager(String name) { this.name...

Understanding join()

Suppose a thread A is running. I have another thread, B, who's not. B has been started, is on runnable state. What happens if I call: B.join()? Will it suspend the execution of A or will it wait for A's run() method to complete? ...