multithreading

Parameter crossing on Threads C# ERROR

Hi, I've a little problem with this code: This is the "main" method of the app: private Thread main_process; private Clases.GestorTR processor; public void begin() { processor = new Clases.GestorTR(); main_process = new Thread(new ThreadStart(processor.ExecuteP)); main_process.Start(); } I've created a Thread to process ot...

question about handling events from an object that throws them from threads

I have a class, ProcessorClass. It has two methods Start() and Stop(). When you hit start, it internally creates a bunch of threads that do some processing and, if they find something relevant, fire an event. My form frmMain (this is a windows forms app .net 3.5) has an instance of this class and is catching these events. Each time a...

How to get the running threads in Android process?

Hey guys!! Is there a way to know all the threads that are currently running in background inside of an Android application?? Thanks!! ...

Python requires a GIL. But Jython & IronPython don't. Why?

Why is it that you can run Jython and IronPython without the need for a GIL but Python (CPython) requires a GIL? ...

why java.util.HashMap.getEntry can block my program ?

Hi, everyone, my program had been blocked , I used the jstack commander to analyze, the following thread took the lock "0x0000000603f02ae0" , and others threads couldn't fetch the lock. I had waited at least one hour, but the thread didn't unlock , my question is why the thread'state is RUNNING, and stop at java.util.HashMap.getEntry(Has...

Writing a thread safe modular counter in Java

Full disclaimer: this is not really a homework, but I tagged it as such because it is mostly a self-learning exercise rather than actually "for work". Let's say I want to write a simple thread safe modular counter in Java. That is, if the modulo M is 3, then the counter should cycle through 0, 1, 2, 0, 1, 2, … ad infinitum. Here's one...

Android Show a dialog until a thread is done and then continue with the program

I am reading a few thousand items out of a database in my Android app and want to show a loading dialog, start a thread and read the database then close the dialog and then populate a listview with the data. I cant seem to figure this out. I have the dialog pop up and disappear but I don't know how to populate the listview after the ...

C++0x "Hello Concurrent World" immediately segfaults on g++/linux?

Browsing through a Currency in C++0x book and thought I would give the sample code a run. It is as basic as it gets. #include <iostream> #include <thread> void hello() { std::cout<<"Hello Concurrent World\n"; } int main(int argc, char *argv[]) { std::thread t(hello); t.join(); } Compiled with: g++ -std=c++0x -g -o pg...

Safe way to capture state of Application?

If I have an Application like this: Class Application { List state1 = new ArrayList(); Map state2 = new HashMap(); } And I have a RPC service run in an other thread that uses to report the state of Application(such as: how many item in state1, which are containing in state2 keys). What's the best way to do that? I'm...

Should this class use data locking for multi threading?

I have a class that contains some data and there are many threads use it: class MyClass { static Dictionary<Key, Value> MyData; static IEnumerable<Data> Data { get { return MyData.Values; } } static void Reset() { MyData = GetMyData(); } } Sometime (say once in...

java call function from multiple threads not declared as thread safe

Hi, There is a JDK function that, although the javadocs does not declare it as thread-safe, from looking at the code in Google, it seems that I could get the result I want by calling it from multiple threads without undesirable side-effects, since the function uses mainly stack variables. So it does not matter if it has synchronized blo...

Calling functions meant for threads normally

I have a function with the prototype DWORD WINAPI blah(LPVOID arg); Which was meant to be used with CreateThread for a threaded app. I call it with CreateThread with no problem. But then somewhere else in the code, I call it normally, just by blah(NULL). When it gets to this part, it crashes. Is this because the WINAPI part makes it ...

Using Django ORM in threads and avoiding "too many clients" exception by using BoundedSemaphore

Hi, I work on manage.py command which creates about 200 threads to check remote hosts. My database setup allows me to use 120 connections, so I need to use some kind of pooling. I've tried using separated thread, like this class Pool(Thread): def __init__(self): Thread.__init__(self) self.semaphore = threadin...

Does anybody know of good resources for parallel programming patterns/testing using .NET 4.0 tasks?

Hi, I recently asked a developer to write a library using the new multithreading capabilities of .NET 4.0. He's done a great job, but I'm concerned that the Task logic is repeated throughout the code and not nicely encapsulated. I'm also concerned that this creates a problem when it comes to testing. Normally, I test by creating a se...

producer-consumer problem:posix mutex got locked twice when using condition variable?

Following code is only to show how to use condition variable to synchronize threads(one producer and many consumers) as exercising. See the line for code 'usleep(100);'.When I comment this line,two consumer threads seem got the mutex locked at the same time after the producer thread exit,and then wait on 'cond',this raise race condition...

How can I decouple this C# worker thread code from the main thread for shared data variables?

How could I modify the below code such that I could, for better readability in code: a) move the "workThreadMethod()" into it's own class b) not have any code in this worker thread class reference static variables from the main "Program" class c) the above are the main two requirements, however I'm hoping that as a side effect this wo...

How to Run C# Threads in Sequence

I have a situation in which I want to start 3 threads called: tr1, tr2 and tr3 I want tr2 to start after tr1 and tr3 to start after tr2. How can I achieve this? ...

Java: multithreaded character stream decoding

I am maintaining a high performance CSV parser and try to get the most out of latest technology to improve the throughput. For this particular tasks this means: Flash memory (We own a relatively inexpensive PCI-Express card, 1 TB of storage that reaches 1 GB/s sustained read performance) Multiple cores (We own a cheap Nehalem server wi...

How to run a thread for a given time period and then return in Java?

I want to create a thread that listens for packets for a given time period (say 30 seconds) and then returns any messages that are received whilst listening. I can do the packet collection stuff, but what is the code pattern for the threading / blocking code that lets the asynch activity run for some set time period? thanks ...

Java and XML (JAXP) - What about caching and thread-safety?

I'd like to know which objects can be reused (in the same or different document) when using the Java API for XML processing, JAXP: DocumentBuilderFactory DocumentBuilder XPath Node ErrorHandler (EDIT: I forgot that this has to be implemented in my own code, sorry) Is it recommended to cache those objects or do the JAXP implementatio...