multithreading

Is `errno` thread-safe?

In errno.h, this variable is declared as extern int errno; so my question is, is it safe to check errno value after some calls or use perror() in multi-threaded code. Is this a thread safe variable? If not, then whats the alternative ? I am using linux with gcc on x86 architecture. ...

Keep threads idle or kill them / restart them?

Pseudo-situation: have a class (let's say BackgroundMagic), and it has Start() and Stop() methods. The work in this class is done by one single thread, and is simply a short loop every X milliseconds. Which of these options is better, as far as managing the stopping/starting? Can't decide which road to take. The first time Start() is ...

Thread-safe, lock-free increment function?

UPDATED: Is there a thread-safe, lock-free and available on all Linux distros increment function available in C or C++ ? ...

Multiple threads in C program

I'm writing a Unix application in C which uses multiple threads of control. I'm having a problem with the main function terminating before the thread it has spawned have a change to finish their work. How do I prevent this from happening. I suspect I need to use the pthread_join primitive, but I'm not sure how. Thanks! ...

Multi-threaded debugging tutorial for GDB and C

Does anybody know of a good GDB (or other Linux debugger) tutorial for debugging multi-threaded C code? I'm looking for one that includes simple examples. ...

ASP.NET Session Variables -- Written by file upload -- Read by XMLHttpRequest to another page.

I am trying to implement a progress bar to monitor a file upload. The file is uploaded in an iframe and the server side C# code behind implements a buffer to upload the file in chunks. It uses a while loop to do this and upload performance seems to be fine with ASP.NET 3.5, and I really do not want to use a 3rd party control or a compl...

How do I give this CPU-intensive Java application a GUI?

I'm writing a little genetic algorithm in Java, as a school assignment. Up until now I've pretty much stuck to doing console applications. However I think a UI would be really helpful for this program, so I'd like to make one. I'm having trouble figuring out how to reconcile a GUI which is event-driven, and a console application which ha...

static event handlers, threading and the like

Hi can anyone explain to me what is happening when a instance of a class declaring a static eventhandler will hold reference to other classes that have registered intent with the event handler in question, being that they are all static would there be any contention between users sessions(I mean his/her usage of the system in a point in...

Replacing ReaderWriterLock with ReaderWriterLockSLim - troubles

Hi, due to performance problems I have replaced RWL with RWLSlim but I am experiencing troubles caused by previously (with RWL) accepted statements. As you can see, sometimes methodA calls another one which have inside ReadLock. The second method is also called from different places, so not always there is lock collision. Previously, Ac...

Message "current thread is in sleep,wait or join state" - locking?

Hi, I have encountered (for me) very strange problem. In my app, when pressing start button, all threads are activated, when pressing stop button, all threads are aborted and all collections are cleared. This is all happen at the main thread, while other procceses have their own threads or are running via threadpool. However, today I rep...

Correct pattern for multi-thread synchronization? (C#)

I have two threads referencing the same variable -- the UI thread and a timer thread. As such, I have wrapped access to it in lock statements in both threads. The timer thread's access has priority -- if it's using the variable and the UI thread also wants access, I want the UI thread's operation to complete, but only after the timer t...

Threading in Ruby with a limit

I have a task I need to perform, do_stuff(opts), that will take ~1s each, even while 1 - 10 of them are running in parallel. I need to collect an array of the results for each operation at the end. If I have 30 stuffs to do, how would I use threading effectively to queue up the do_stuff(opts) operations so no more than 10 are running co...

Python threading appears to run threads sequentially

Sorry if this is a very stupid question. I am trying to use threads in a Python project I am working on, but threads don't appear to be behaving as they are supposed to in my code. It seems that all threads run sequentially (i.e. thread2 starts after thread 1 ends, they don't both start at the same time). I wrote a simple script to test ...

Run a modal dialog on a non-UI thread

I'm writing a simple data UI using standard .Net databinding to a typed DataSet from SQL Server. I have a reload button which calls Fill on all of the DataAdapters to get new data from the database (in case another user changed the data). This takes some time, during which the UI is frozen. It must be run on the UI thread or the datab...

C++ multithreading: explicit locks in domain model classes

Guys, I'm developing a multiplayer game application with C++ and currently in the process of choosing an appropriate multithreading architecture for it. The core of the application is the endless loop which essentially updates each frame all entities of the game World. Currently this World loop is singlethreaded. It's working just fine...

How to implement efficient sorting algorithms for multiple processors with Scala?

How to implement efficient sorting algorithms for multiple processors in Scala? Here's the link for radix algorithm in GPU: radix algorithm in GPU ...

win32com and PAMIE web page open timeout

Hello, currently im making some crawler script,one of problem is sometimes if i open webpage with PAMIE,webpage can't open and hang forever. are there any method to close PAMIE's IE or win32com's IE ? such like if webpage didn't response or loading complete less than 10sec or so . thanks in advance ...

weird error when passing pthread_t to function

I have a C header file which defines the following function: void my_func(pthread_t tid); This is defined by another function: void my_func(pthread_t tid) { ... When I compile, it says: ****.h:2: error: expected specifier-qualifier-list before ‘pthread_t’ Any ideas what I'm doing wrong? ...

Using lock with Threading.Timer

Hi, I have a Windows Service application which uses a Threading.Timer and a TimerCallback to do some processing at particular intervals. I need to lock down this processing code to only 1 thread at a time. So for example, the service is started and the first callback is triggered and a thread is started and begins processing. This work...

WPF Threading question better option.

Hi Here are the 2 ways we are using trying to use thread/dispatcher for multi tasking a few things: I am wondering if anyone has any suggestions which one is better option. Snippet 1: Thread t = new Thread(new ThreadStart(delegate { MyMethod(); })); t.IsBackground = true; t.Start(); t....