multithreading

How can I kill a Perl system call after a timeout?

I've got a Perl script I'm using for running a file processing tool which is started using backticks. The problem is that occasionally the tool hangs and It needs to be killed in order for the rest of the files to be processed. Whats the best way best way to apply a timeout after which the parent script will kill the hung process? At t...

Semaphore race condition?

I have created a "Manager" class that contains a limited set of resources. The resources are stored in the "Manager" as a Queue. I initialize the Queue and a Semaphore to the same size, using the semaphore to block a thread if there are no resources available. I have multiple threads calling into this class to request a resource. Her...

Multithreading in PHP

I am working on windows. I have built a twitter application using the twitter API which periodically checks for new tweets as well as allows users to update their status. I have written separate PHP files for reading (reader.php) and writing tweets (writer.php). The only problem is how do I periodically read the tweets. There are a few w...

Fast inter-process (inter-threaded) communications IPC on large multi-cpu system.

What would be the fastest portable bi-directional communication mechanism for inter-process communication where threads from one application need to communicate to multiple threads in another application on the same computer, and the communicating threads can be on different physical CPUs). I assume that it would involve a shared memory...

how to send some data to the Thread module on python and google-map-engine

from google.appengine.ext import db class Log(db.Model): content = db.StringProperty(multiline=True) class MyThread(threading.Thread): def run(self,request): #logs_query = Log.all().order('-date') #logs = logs_query.fetch(3) log=Log() log.content=request.POST.get('content',None) log.put() ...

Howto access thread data outside a thread

Question: I start the MS Text-to-speech engine in a thread, in order to avoid a crash on DLL_attach. It starts fine, and the text to speech engine gets initialized, but I can't access ISpVoice outside the thread. How can I access ISpVoice outside the thread ? It's a global variable after all... You find XPThreads here: http://www.codepr...

C# Process Binary File, Multi-Thread Processing

I have the following code that processes a binary file. I want to split the processing workload by using threads and assigning each line of the binary file to threads in the ThreadPool. Processing time for each line is only small but when dealing with files that might contain hundreds of lines, it makes sense to split the workload. My q...

Java threadpool functionality

Hi stackoverflow, I need to make a program with a limited amount of threads (currently using newFixedThreadPool) but I have the problem that all threads get created from start, filling up memory at alarming rate. I wish to prevent this. Threads should only be created shortly before they are executed. e.g.: I call the program and instr...

Do breakpoints introduce delay?

How is that setting a breakpoint in my code allows the following code to complete which would fail otherwise. Here is the problem. I'm writing an add-on for SAP B1 and encountered following problem. When I load a form I would like to enter some values into the form' matrix. But without a breakpoint (set on a method in which loading a...

Dispatcher.CheckAccess() isn't working from my console application, is there a better way.

I wrote an application in WPF / VB and separated the business logic and UI into different projects. The business layer uses a serial port which runs on a different thread, Now that I'm trying to write a command line interface for the same business layer, it seems to fail when .Invoke() is called. (no error, just doesn't work) I'm pre...

Response.Redirect not firing due to code to prevent re-submission

I have an event which needs to contact some third party providers before performing a redirect (think 'final payment page on ecommerce site') and hence has some lag associated with its processing. It is very important that these third party providers are not contacted more than once, and sometimes impatient users may try and refresh the ...

How to deal with OpenMP thread pool contention

I'm working on an application that uses both coarse and fine grained multi-threading. That is, we manage scheduling of large work units on a pool of threads manually, and then within those work units certain functions utilize OpenMP for finer grain multithreading. We have realized gains by selectively using OpenMP in our costliest loops...

Java: Multithreading & UDP Socket Programming

I am new to multithreading & socket programming in Java. I would like to know what is the best way to implement 2 threads - one for receiving a socket and one for sending a socket. If what I am trying to do sounds absurd, pls let me know why! The code is largely inspired from Sun's tutorials online.I want to use Multicast sockets so that...

Should I use multiple threads in this situation? [Ruby]

I'm opening multiple files and processing them, one line at a time. The files contain tokens separating the data, such that sometimes the processing of one file may have to wait for others to catch up to that same token. I was doing this initially with only one thread and an array indicating with true/false if the file should be read in...

Is System.nanoTime() consistent across threads?

I want to count the time elapsed between two events in nanoseconds. To do that, I can use System.nanoTime() as mentioned here. The problem is that the two events are happening in different threads. Since nanoTime() doesn't return an absolute timestamp but instead can only be used to calculate time differences, I'd like to know if the...

Please help. Creating threads and wait till finsh

Hi I have two method calls that I want to call using two threads. Then I want them to wait till method executions get completed before continuing. My sample solution is something like below. public static void Main() { Console.WriteLine("Main thread starting."); String[] strThreads = new String[] { "one", "tw...

Is a HashMap thread-safe for different keys?

If I have two multiple threads accessing a HashMap, but guarantee that they'll never be accessing the same key at the same time, could that still lead to a race condition? ...

How to close all running threads?

When i used foreach (Form form in Application.OpenForms) { form.Close(); } Application.Exit(); It not exit Application? How can I exit the application making sure all running thread are closed? ...

Thread runs only once

When a Thread is finished, you cannot run it once more, using start() method: it throws an Exception. Could anyone explain, why? What stands behind such an architectural decision? ...

How to call a function though Control.BeginInvoke in a signal-slot-like fashion?

I'd like a delegate that calls a function in a different thread when it is invoked. Currently, I'm using the following implementation: delegate void someFunctionDelegate(); //... someFunctionDelegate callBackFunction = someForm.SomeFunction; someForm.Invoke(someFunctionDelegate); However, I'd like a more compact form, combining both ...