multithreading

Procedure entry point InitializeConditionVariable could not be located in kernel32.dll

I am running producer consumer problem( using windows thread ).It compiling successfully but on running it showing following error The procedure entry point InitializeConditionVariable could not located in the dynamic library Kernel32.dll. can u tell what would be reason ...

Strange C++ thread function invocation

I have the following: class DThread { virtual void run()=0; _beginthreadex(NULL,0,tfunc,this,0,&m_UIThreadID); // class itself being passed as param to thread function... static unsigned int __stdcall tfunc(void* thisptr) { static_cast<DThread*>(thisptr)->run(); return 0; }...

Does MultiThreading in Java takes much time for task completion?

I have to search for a string in 10 large size files (in zip format 70 MB) and have to print the lines with the search string to corresponding 10 output files.(i.e. file 1 output should be in output_file1...file2---> output_file2). The same program takes 15 mins for a single file. But if use 10 threads to read 10 files and to write in 10...

Wait on multiple condition variables on Linux without unnecessary sleeps?

I'm writing a latency sensitive app that in effect wants to wait on multiple condition variables at once. I've read before of several ways to get this functionality on Linux (apparently this is builtin on Windows), but none of them seem suitable for my app. The methods I know of are: Have one thread wait on each of the condition variab...

How can I use boost::thread::id as key to an unordered_map?

According to the documentation, a boost::thread::id can be considered unique for each running thread and can be used in containers such as std::set and std::map (because the < operator is overridden for thread::id). My problem is that I'd like to use thread::id as a key to an boost::unordered_map, however it requires that the key is "ha...

How can I load file into web app through certain periods?

Hi all! I have next task: I need to load the same file into my web app several times, for example - twice a day! Suppose in that file I have information, that changes, and I need to load this info into my app to change the statistics for example. How can I load file several times (twice an hour, or twice a day)? What should I use? Is an...

Parent Thread exiting before Child Threads [python]

I'm using Python in a webapp (CGI for testing, FastCGI for production) that needs to send an occasional email (when a user registers or something else important happens). Since communicating with an SMTP server takes a long time, I'd like to spawn a thread for the mail function so that the rest of the app can finish up the request witho...

Java invokeAndWait of C# Action Delegate

the issue i mentioned in this post is actually happening because of cross threading GUI issues (i hope). could you help me with Java version of action delegate please? in C# it is done as this inline: this.Invoke(new Action(delegate() {...})); how is this achived in Java? thank you. public class processChatMessage ...

ProgressBar not reset to "0" when opening the second time.

In an Android application I run a task in a separate thread. While the thread is running it updates a progress bar in the main window to let the user know what's going on. The problem is, that if a user starts the thread a second time the progress bar won't be reset. It will just sit on 100% without doing anything. The whole source is a...

performSelectorOnMainThread equivalent in Java for Android

I have an iPhone application and I am porting it over to Android. I have a service/controller that spawns new threads to perform some network tasks. I use performSelectorOnMainThread in my iPhone app. How can I have my Java app do the same or similar thing? ...

On-Demand Python Thread Start/Join Freezing Up from wxPython GUI

I'm attempting to build a very simple wxPython GUI that monitors and displays external data. There is a button that turns the monitoring on/off. When monitoring is turned on, the GUI updates a couple of wx StaticLabels with real-time data. When monitoring is turned off, the GUI idles. The way I tried to build it was with a fairly sim...

What happens if you break out of a Lock() statement?

I'm writing a program which listens to an incoming TcpClient and handles data when it arrives. The Listen() method is run on a separate thread within the component, so it needs to be threadsafe. If I break out of a do while loop while I'm within a lock() statement, will the lock be released? If not, how do I accomplish this? Thanks! (A...

Efficiency of while(true) ServerSocket Listen

I am wondering if a typical while(true) ServerSocket listen loop takes an entire core to wait and accept a client connection (Even when implementing runnable and using Thread .start()) I am implementing a type of distributed computing cluster and each computer needs every core it has for computation. A Master node needs to communicate w...

Self-updating collection concurrency issues

I am trying to build a self-updating collection. Each item in the collection has a position (x,y). When the position is changed, an event is fired, and the collection will relocate the item. Internally the collection is using a “jagged dictionary”. The outer dictionary uses the x-coordinate a key, while the nested dictionary uses the y-...

Is my way of doing threads in Android correct?

Hi, I'm writing a live wallpaper, and I'm forking off two separate threads in my main wallpaper service. One updates, and the other draws. I was under the impression that once you call thread.start(), it took care of everything for you, but after some trial and error, it seems that if I want my update and draw threads to keep running,...

Thread does not abort on application closing

I have an application which does some background task (network listening & reading) in separate Thread. It seems however that the Thread is not being Terminated/Aborted when I close the application (click "x" button on titlebar ;)). Is that because the main Thread routine is while(true) {...} ? What is the solution here? I was looking fo...

Groovy concurrency: A better way to aggregate results semantically?

I need to call a number of methods in parallel and wait for results. Each relies on different resources, so they may return at different times. I need to wait until I receive all results or time out after a certain amount of time. I could just spawn threads with a reference to a shared object via a method call, but is there a better, mo...

PyQt threads and signals - how to properly retrieve values

Using Python 2.5 and PyQt 4.4.3, I couldn't find any question this specific in Python, so sorry if I'm repeating the other Qt referenced questions below, but I couldn't easily understand that C code. I've got two classes, a GUI and a thread, and I'm trying to get return values from the thread. I've used the link in here as base to write...

Using sigprocmask to implement locks

I'm implementing user threads in Linux kernel 2.4, and I'm using ualarm to invoke context switches between the threads. We have a requirement that our thread library's functions should be uninterruptable by the context switching mechanism for threads, so I looked into blocking signals and learned that using sigprocmask is the standard ...

.NET Threading : How to wait for other thread to finish some task

Assume I have method void SomeMethod(Action callback) This method does some work in background thread and then invokes callback. The question is - how to block current thread until callback is called ? There is an example bool finished = false; SomeMethod(delegate{ finished = true; }); while(!finished) Thread.Sleep(); But I'm sur...