multithreading

Parallelization: pthreads or OpenMP?

Most people in scientific computing use OpenMP as a quasi-standard when it comes to shared memory parallelization. Is there any reason (other than readability) to use OpenMP over pthreads? The latter seems more basic and I suspect it could be faster and easier to optimize. ...

Server process with PHP+MySQL

I am new to web programming, and I am developing a simple appointment app with PHP + MySQL. Is there a simple way to add a background process on a timer (to send out daily appointment reminders, for example)? This could be done easily in another language, but I want it to run on shared hosting with only PHP. ...

System.Threading.Thread inheritance

Is it possible to inherit from the Thread class and override the Start method? ...

Threading in J2EE webapps

I am curious about how the following concepts typically execute inside a J2EE container, is one instance created per request, or does one instance serve all requests? Servlets Tags I want to know this because lately i have been using a lot of StringBuffers in my custom tags, avoiding StringBuilder because it is not thread safe. Id li...

How do I pass an exception between threads in python

I need to pass exceptions across a thread boundary. I'm using python embedded in a non thread safe app which has one thread safe call, post_event(callable), which calls callable from its main thread. I am running a pygtk gui in a seperate thread, so when a button is clicked I post an event with post_event, and wait for it to finish bef...

BoundedSemaphore hangs in threads on KeyboardInterrupt

If you raise a KeyboardInterrupt while trying to acquire a semaphore, the threads that also try to release the same semaphore object hang indefinitely. Code: import threading import time def worker(i, sema): time.sleep(2) print i, "finished" sema.release() sema = threading.BoundedSemaphore(value=5) threads = [] for x in ...

Pthread - What is the difference between time.h::sleep() and pthread.h::pthread_yield()?

I spent a good long while looking for info on the differences between time.h::sleep() and pthread.h::pthread_yield() but was unable to find any solid reference material and so I am posting this question. What is the difference between time.h::sleep() and pthread.h::pthread_yield()? Update: The reason I ask is because I was using sleep...

What is the safest/proper way to implement a thread-safe singleton pattern?

How do I implement the singleton pattern in C# and ensure that it is thread safe? ...

What are some common pitfalls developers run into with multi-threading?

Possible Duplicate: What are common concurrency pitfalls? I have basic knowledge of threading, nothing specific. Some co-workers and I are studying for a certification and we are on the chapter about multi-threading. What are some common mistakes you make when implementing a multi-threaded application? When developing a mu...

Is it better to poll or wait?

I have seen a question on why "polling is bad", but I am wonderring, in terms of minimizing the amount of processor time used by one thread, would it be better to do a spin wait (i.e. poll for a required change in a while loop) or wait on a kernel object (e.g. a kernel event object in windows)? For context, assume that the code would be...

Spring-AOP & MultiThreading

i am having trouble multithreading my app. It seems AOP is unable to span over multiple threads i.e. i am unable to execute all the threads within a single transaction. Every thread updates the database on processing. I am using fixedThreadPool and ExecutorCompletionService. Is this a problem with spring? ...

destructor of static class need a mutex?

We have a static (singleton) class which will be used in a mutithreaded environment. We use mutex in its constructor and other mrmber functions. However there is no mutex for the destructor. Destructor do some tasks like cleaning up of some other member objetcs etc. Do we need to a mutex in the distructor also ? ...

Ehcache & MultiThreading

Does ehcache support multi-threading by default or does it require any configuration changes? On multi threading my application with Ehcache i found that the DB hit count is actually increasing i.e. there is no global cache available for all the threads despite the fact that my cache's are all Singletons. Any suggestions? ...

Threading In Python

I'm new to threading and was wondering if it's bad to spawn a lot of threads for various tasks (in a server environment). Do threads take up a lot more memory/cpu compared to more linear programming? ...

How to prevent swing GUI locking up during a background task

Hi, I have a swing application which stores a list of objects. When the users clicks a button, I want to perform two operations on each object in the list, and then once that is complete, graph the results in a JPanel. I've been trying SwingWorker, Callable & Runnable to do the processing, but no matter what I do, while processing the l...

C# Simple Countdown - What am I doing wrong?

I wanted to make a simple Countdown-Application with C# to show as an example. For the very first and basic version I use a Label to display the current time left in seconds and a Button to start the countdown. The Button's Click-Event is implemented like this: private void ButtonStart_Click(object sender, RoutedEventArgs e) { ...

Dual-queue producer-consumer in .NET (forcing member variable flush)

I have a thread which produces data in the form of simple object (record). The thread may produce a thousand records for each one that successfully passes a filter and is actually enqueued. Once the object is enqueued it is read-only. I have one lock, which I acquire once the record has passed the filter, and I add the item to the back...

pygtk gui freezes with pyjack thread

Hello I have a program that records audio from firewire device (FA-66) with Jack connection. The interface is created with pygtk and the recording with py-jack (http://sourceforge.net/projects/py-jack/). The recording is done in a different thread because the GUI must be used at the same time for viewing results from the audio. The pro...

Threads in java

int iThreadCount = 1; iThreadCount = GHMTreadUtil.getHygThreadCount(); arrHygThread = new Thread[iThreadCount]; for(int iCount=0;iCount<iThreadCount;iCount++) { LogMgr.logDebugInfo("spawning the HYG Thread"+iCount,objDebug); Job1 objJob1=new Job1 (); Job2 objJob2 =new Job2 (); Thread objHygThread = new Thread(objJob1,ob...

C#: Wait for variable to become non-null.

.Net's odd locking semantics are bugging me again. I'm launching a thread, the child thread in turns starts a form. The parent thread should wait until the form is created. My first attempt was to use a Monitor to watch the Form variable: private void OpenForm() { if (FormThread == null) { Monitor.Enter(Form); ...