multithreading

Multiple threads filling up their result in one DataTable C#

Hi All, I'm just beginning to learn the concept of threading, and I'm kind of stuck at this one problem, its driving me crazy.... What I actually need to accomplish - I have some 300 text files in a local directory, that need to be parsed for specific values... After I find these "values" in each text file, I need to store them in a d...

using wxWidgets in a GLUT/other application

I'm basicly looking to get a native-like window GUI system into my OpenGL/Game. I need to display a single window to the user. I'm looking into wxWidgets. Because it works by "stealing" the WinMain/MainLoop, I'm trying to hack it so I can run its main loop on a separate thread. Because I couldn't get its wxThread working well, I've do...

Example for boost shared_mutex (multiple reads/one write)?

I have a multithreaded app that has to read some data often, and occasionally that data is updated. Right now a mutex keeps access to that data safe, but it's expensive because I would like multiple threads to be able to read simultaneously, and only lock them out when an update is needed (the updating thread could wait for the other thr...

Why aren't variables in Java volatile by default?

Possibly similar question: http://stackoverflow.com/questions/106591/ Today I was debugging my game; It had a very difficult threading problem that would show up every few minutes, but was difficult to reproduce. So first I added the synchronized keyword to each of my methods. That didn't work. Then I added the volatile keyword to ever...

Python Global Interpreter Lock (GIL) workaround on multi-core systems using taskset on Linux?

So I just finished watching this talk on the Python Global Interpreter Lock (GIL) http://blip.tv/file/2232410. The gist of it is that the GIL is a pretty good design for single core systems (Python essentially leaves the thread handling/scheduling up to the operating system). But that this can seriously backfire on multi-core systems an...

Any single-consumer single-producer lock free queue implementation in C?

I'm writing a program with a consumer thread and a producer thread, now it seems queue synchronization is a big overhead in the program, and I looked for some lock free queue implementations, but only found Lamport's version and an improved version on PPoPP '08: enqueue_nonblock(data) { if (NULL != buffer[head]) { return EWO...

Simple Thread Management - Java - Android

Hi, I have an application which spawns a new thread when a user asks for an image to be filtered. This is the only type of task that I have and all are of equal importance. If I ask for too many concurrent threads (Max I ever want is 9) the thread manager throws a RejectedExecutionException. At the minute what I do is; // Manage Co...

Difference between Barrier in C# 4.0 and WaitHandle in C# 3.0?

I am picking up C# 4.0 and one of the things which is confusing me, is the barrier concept. Is this not just like using the WaitAll method of WaitHandle? Doesn't that wait for all threads to finish? I learnt the barrier construct from this page: http://www.managed-world.com/archive/2009/02/09/an-intro-to-barrier.aspx However, it seems...

gcc optimize busy waiting as dead loop

I'm implementing a single-producer single-consumer queue, by which one thread waits for the global queue to be filled by another thread like this: while (queue.head == queue.tail); When I compiled the program will gcc -O0, it worked well. But when it was compiled with gcc -O1, deadloop happened. Then I looked into assembly code and fo...

Why is there no GIL in the Java Virtual Machine? Why does Python need one so bad?

I'm hoping someone can provide some insight as to what's fundamentally different about the Java Virtual Machine that allows it to implement threads nicely without the need for a Global Interpreter Lock (GIL), while Python necessitates such an evil. ...

C# The best way to callback a client application with interim results from a pool of threads.

I have written a C# library which has a method to count words from multiple passages of text in parrallel. The passages of text are given as character streams where there is a random delay each time getnextchar() is called. My library method has to take an array of these character streams and return a combined word-frequency count. To...

Can client side python use threads?

I have never programed in Python before, so excuse my code. I have this script that will run in a terminal but I can't get it to run client side. I am running this in Appcelerator's Titanium application. Anyway, I have been troubleshooting it and it seems that it isn't running the threads at all. Is this a limitation? does anyone know? ...

Directory walker on modern operating systems slower when it's multi-threaded?

Hello! Once I had the theory that on modern operating systems multithreaded read access on the HDD should perform better. I thought that: the operating system queues all read requests, and rearranges them in such a way, that it could read from the HDD more sequentially. The more requests it would get, the better it could rearrange the...

ASP.Net static objects

I'm trying to cache some information that I've retrieved from a database. I've decided to use a static List<> member to store the information. I know from my experience with List<> in multithreaded applications that I need to protect access to it with the lock statement. Do I treat any code in my Asp.Net code the exact same way? Will the...

Thread safety... what's my "best" course of action?

I'm wondering what is the "best" way to make data thread-safe. Specifically, I need to protect a linked-list across multiple threads -- one thread might try to read from it while another thread adds/removes data from it, or even frees the entire list. I've been reading about locks; they seem to be the most commonly used approach, but ap...

Cocoa: NSOpenPanel Threads

I am monitoring my application using Activity Monitor and whenever NSOpenPanel is called the application appears as having 9 threads and stays like that until the application is closed. Is there a way to release those threads?, Or am I simply misunderstanding what the threads number means?, surely it isn't a good thing to have them open...

How do I display a loading icon while a Frame navigates?

I have a WPF application with a Frame and a TreeView. The TreeView displays the menu for my application, and when an item is clicked, the Frame displays the content for that menu item via a call to Navigate. That call sometimes takes several seconds, and UI is blocked while navigation completes. I have a control with animated spinning...

Using Thread.Sleep() in a Windows Service

I'm writing a windows service that needs to sleep for long periods of time (15 hrs is the longest it will sleep, 30 mins is the shortest). I'm currently using Thread.Sleep(calculatedTime) to put my code into sleep mode. Is Thread.Sleep the best option or should I be using a timer? I've been googling this for a while and can't find a c...

Make my code handle in the background function calls that take a long time to finish

Certain functions in my code take a long time to return. I don't need the return value and I'd like to execute the next lines of code in the script before the slow function returns. More precisely, the functions send out commands via USB to another system (via a C++ library with SWIG) and once the other system has completed the task, it ...

how do you pass binary messages to/from a javascript web worker?

I'm building a multi-threaded client side javascript application, and I would like to have a background thread pull binary data and pass it to the main thread. I know this can be done in other languages via serialization, but how do I accomplish this in javascript? ...