multithreading

OutOfMemoryError in a separate Java thread

Consider that I have a main Thread which executes a new Runnable in a new Thread. Now, while the new Thread is executing, the Java VM runs out of memory and throws an OutOfMemoryError. What happens? Does the target thread stop? Will the main thread continue? When the new Thread crashes, will the VM reclaim the memory from it and let exe...

IllegalMonitorStateException on wait() call

I am using multi-threading in java for my program. I have run thread successfully but when I am using Thread.wait(), it is throwing java.lang.IllegalMonitorStateException. How can I make a thread wait until it will be notified? ...

Can I call multiple FFMPEG processes on a multi-core LAMP machine from PHP?

I am using PHP to call an FFMPEG command using exec(). The script that initiates this command is called from another PHP script using proc_close(proc_open('php /phpdirectory/process.php &', array(), $foo)); This works great. The ffmpeg command is called and runs 'in the background' leaving the first script to return to the user and i...

User initiated background process in a web application

I have a java web application wired using Spring on Tomcat. I need a way for a user to initiate a background process in the server and return a response to the user without waiting for the background process to complete. The background process is programmed in java and integrated with my application. Since i am using tomcat JMS is no...

Cannot create a for loop inside a java thread - why?

Hi, my code is as follows public void incomingMessageThread() throws FileNotFoundException, IOException { new Thread() { BuildData a = new BuildData(); for(int i = 0; i<100; i++) { a.parseDataFile("_"+i+"/outgoingMessages"); } }.start(); } I get told its an illegal start of ...

Why does Thread.Join take so long to return?

I'm calling Thread.Join on a ThreadPool thread at the end of a service. The code executed in the thread ends about the same time as Thread.Join is called, but the Join takes 2 minutes to return. Why is it taking 2 minutes for Thread.Join to return. The log: (2009-10-08 14:22:09) Inf: ProcessRequests - Interrupted, exiting. (2009-10-0...

Is this thread safe? (shared data without mutex/semaphore)

So this is a very particular question: I use an embedded system with a single CPU core. I have one main thread and an interrupt. They share a 32-bit float. The interrupt writes the float, and the main thread reads it. Reads and writes are not synchronized. The processor documentation states that the 32-bit read is a one-cycle operatio...

[C#] A problem with MyThread and the Timer Control

Hi, I have e.g that method, which is being invoked in the second Thread: public byte[] ReadAllBytesFromStream(Stream input) { clock.Start(); using (...) { while (some conditions) //here we read all bytes from a stream (FTP) { ... (int-->) ByteCount = aValue;...

How to report timeout in Asynchronous call ?

I am learning threading.My intension is to pass some values to a method for calculation,if the result will not be returned within 20 ms,i will report "Operation timeout".Based on my understading i have implemented the code as follows: public delegate long CalcHandler(int a, int b, int c); public static void ReportTimeout() { ...

Trace/BPT trap with Python threading module

The following code dies with Trace/BPT trap: from tvdb_api import Tvdb from threading import Thread class GrabStuff(Thread): def run(self): t = Tvdb() def main(): threads = [GrabStuff() for x in range(1)] [x.start() for x in threads] [x.join() for x in threads] if __name__ == '__main__': main() The error...

Is this lock-free .NET queue thread safe?

My question is, is the class included below for a single-reader single-writer queue class thread-safe? This kind of queue is called lock-free, even if it will block if the queue is filled. The data structure was inspired by Marc Gravell's implementation of a blocking queue here at StackOverflow. The point of the structure is to allow a ...

Problem : InvokeRequired is always False when trying to show the form in c# windows application

I am trying to implement single instance of the form. Because my application is all about hiding and showing different form dynamically according to some runtime values. when i want to show the Trainee_Login form from a class file, i do this... Trainee_login ShowTraineelogin = Trainee.login.TraineeloginRef; ShowTraineelogin.ShowScreen...

How to find the Number of CPU Cores via .NET/C#?

Hi, Is there a way via .NET/C# to find out the number of CPU cores? Thanks! PS This is a straight code question, not a "Should I use multi-threading?" question! :-) ...

Threads - Simulation of execution time

I have two secondary threads,that executes the method WriteX as described below: static void Main(string[] args) { ThreadStart one = new ThreadStart(WriteX); Thread startOne = new Thread(one); ThreadStart two = new ThreadStart(WriteX); Thread startTwo = new Thread(two); startOne.Start(); ...

StopWatch (System.Diagnostics) and System.Timers

I am new to handling threads. What is the role of System.Diagnostics and System.Timers in the context of Threading ? Both are alternative to each other or they implemented for doing some unique tasks? ...

Multithreading on ASP .NET 2.0 (begginer question)

I have to make a few request to get some data from third party services. As response time from each petition can range from a few seconds to a full minute, I've thinking that would be a good case for implement a multi-thread solution (as seen in this question) but as I haven't used it before, I'm not sure how to implement it. I have to...

How to do Dynamic allocation of task to Threads in java?

Hi, i am trying to do an application,like if there are 10 separate tasks and 4 threads are running.My application has to maintain two queue one for tasks and another for threads.If any task needs to execute it should find which thread is free and assign the task to that thread.i dont know how to produce this.Anyone knows what are the co...

How to know which task a Thread is exceuting at the specific time in java?

Hi, I am assigning task randomly to threads,and at a specific time how to get the task name running on a particular thread.Please anyone help me. ...

QTcpSocket in QThread

I have simple server connection thread. When you call function receiveString, it fails. However when you execute same code in run(), it succeeds. What is needed for function receiveString to work? I've tried both bool TestServerThread::receiveString(QTcpSocket& sock, QString& str) bool TestServerThread::receiveString(QTcpSocket* sock, ...

What's the standard approach to making calculations thread-safe?

What initially seemed like a problem with an easy solution has proven to be quite an interesting challenge. I have a class which maintains an internally fixed-size, thread-safe collection (by way of using lock on all insertion and removal operations) and provides various statistical values via its properties. One example: public doubl...