multithreading

How to use boost::thread mutex to synchronize write access?

I have a newbie question about Boost::Thread and Mutex. I would like to start many parallel instances of the following Worker, and all of them write to the same std::vector: struct Worker { std::vector<double>* vec; Worker(std::vector<double>* v) : vec(v) {} void operator() { // do some long computation and then add results t...

Asynchronous Delegate Invocation (ADI) vs. Task Parallel Library (TPL)

I get this comment on ADI while reading Essential C# 4.0: Unfortunately, the underlying technology used by the asynchronous delegate invocation pattern is an end-of-further-development technology for distributed programming known as remoting. And although Microsoft still supports the use of asynchronous delegate invocat...

Threads vs Processes

Possible Duplicate: What are the thread limitations when working on Linux compared to processes for network/IO-bound apps? What is meant by context switches in threads or processes ? Also which is better : Threads or Processes ? I mean which is more space efficient and which is more time efficient ? ...

Raw input and printing simultaneously

So I have a threaded Python program that takes input from a user and prints data simultaneously. The problem is that when the program is sitting at raw_input(), it won't print anything and will print it all after the user presses enter. Is there any way to have user input and print at the same time? ...

Non-block vs select() call in socket

I have to implement a game server in C which handles multiple clients and continuously exchange information with them. The client may not be sending information at all times.Should I assign a thread with non-blocking socket to them or use select() call. Which one is better? ...

How to properly release an AVCaptureSession

I'm using the AV Foundation classes to capture the live video stream from the camera and to process the video samples. This works nicely. However, I do have problems properly releasing the AV foundation instances (capture session, preview layer, input and output) once I'm done. When I no longer need the session and all associated object...

Ordering threads to run in the order they were created/started

Hi, How can i order threads in the order they were instantiated.e.g. how can i make the below program print the numbers 1...10 in order. public class ThreadOrdering { public static void main(String[] args) { class MyRunnable implements Runnable{ private final int threadnumber; MyRunnable(int thread...

Thread Safe web apps - why does it matter?

Why does being thread safe matter in a web app? Pylons (Python web framework) uses a global application variable which is not thread safe. Does this matter? Is it only a problem if I intend on using multi-threading? Or, does it mean that one user might not have updated state if another user... I'm just confusing myself. What's so importa...

Events and delegates, how do I code it 2 levels deep?

Class1 creates and calls a method in Class2. Class2's method updates it progress to an event handler in Class1. But now Class2's method needs to call a method in class3. How can class3 update it's method's progress to class1? Do I need to daisy chain the events and delegates all the way down each level? (I'm using the MVC pattern, The U...

.NET Threading - Quick question

What should I put instead of the "SomeType" in the below function? Delegate seems to be wrong here.. public static void StartThread(SomeType target) { ThreadStart tstart = new ThreadStart(target); Thread thread = new Thread(tstart); thread.Start(); } EDIT: I'm not looking for alternative ways to write this. ...

Boost threads: is it possible to limit the run time of a thread before moving to another thread.

I have a program with a main thread and a diagnostics thread. The main thread is basically a while(1) loop that performs various tasks. One of these tasks is to provide a diagnostics engine with information about the system and then check back later (i.e. in the next loop) to see if there are any problems that should be dealt with. An...

How do I use Perl's `Thread::Pool::Simple`?

I'm using Thread::Pool::Simple for multi-threading. I have a couple of questions which are quite general to multi-threading, I guess: Each of my threads might die if something unexpected hapens. This is totally accepted by me, since it means some of my assertion are wrong and I need to redesign the code. Currently, when any thread dies ...

Is there an upper limit to stack size for secondary threads for iPhone?

In building an iPhone app, I created a secondary thread to handle real-time tasks. Apple Developer documentation seems to indicates a "recommended/maximum" stack size of 512KB (524288 bytes) for secondary threads. http://developer.apple.com/library/ios/#documentation/Cocoa/Conceptual/Multithreading/CreatingThreads/CreatingThreads.html ...

How can I change the current directory in a thread-safe manner in Perl?

I'm using Thread::Pool::Simple to create a few working threads. Each working thread does some stuff, including a call to chdir followed by an execution of an external Perl script (from the jbrowse genome browser, if it matters). I use capturex to call the external script and die on its failure. I discovered that when I use more then one...

java thread reusage via executor

Hi, I am confused on the following: To use threads in a Java program, the simplest way is to extend Thread class and implement the runnable interface (or simply implement runnable). To start the thread's execution. we must call the Thread's method start(), which in turn calls method run() of the thread. And so the thread starts. The met...

Threading UI updates in Android

Hey guys, I've just started with android development and updating the UI is really bugging me :/ This is what I've got working so far - package projects.Move; import android.os.Bundle; import android.view.View; import android.app.Activity; import android.content.Context; import android.graphics.Canvas; import android.graphics.Paint...

C# WinForm Timers - Notify parent class that a timer event has been raised.

I have a parent class that contains an array of objects each with a timer associated with it. I want the parent class to be able to start and stop these timers, and most importantly want the parent class to detect which of the it's child objects 'timer elapsed' even has been raised. Is this possible and if so what is the best way to do...

Race conditions with java references

Hi, The atomic integer, long, boolean etc are used to do any atomic updates to the respective types since there may be a race condition when we execute any manipulation on them, e.g ++. But what are the different cases with references where there may be such race conditions? Best Regards, Keshav ...

What is recommended way for spawning threads from a servlet in Tomcat

Probably a repeat! I am using Tomcat as my server and want to know what is best way to spawn threads in the servlet with deterministic outcomes. I am running some long running updates from a servlet action and would like for the request to complete and the updates to happen in the background. Instead of adding a messaging middleware like...

Python threading passing statuses

Basically what I'm trying to do is fetch a couple of websites using proxies and process the data. The problem is that the requests rarely fail in a convincing way, setting socket timeouts wasnt very helpful either because they often didn't work. So what I did is: q = Queue() s = ['google.com','ebay.com',] # And so on for item in s: ...