multithreading

How can I impose my own timeout?

I have to use an API to make a call to a third party, and ideally use the response it returns. The API has a built-in 30 second timeout, and does not allow you to set that programatically. I need it to time out in 12 seconds. Here's the call I'm making: string response = theAPI.FunctionA(a, b, c, d); I've been thinking I might need ...

Why spawning threads in J2EE container is discouraged?

One of the first things I've learned about J2EE development is that I shouldn't spawn my own threads inside a J2EE container. But when I come to think about it, I don't the reason. Can you provide a clear explanation why it is discouraged? I am sure most enterprise applications need some kind of asynchronous jobs like mail daemons, idl...

C# Managed Thread Cleanup

After my application creates a thread using a ParameterizedThreadStart delegate, that thread performs some initialization and runs to completion. Later on, I can observe that this thread is no longer active because its IsAlive property is false and ThreadState property is ThreadState.Stopped. Once a thread reaches this state they rem...

How do I tear down observer relationship in multithreaded C++?

I have a Subject which offers Subscribe(Observer*) and Unsubscribe(Observer*) to clients. Subject runs in its own thread (from which it calls Notify() on subscribed Observers) and a mutex protects its internal list of Observers. I would like client code - which I don't control - to be able to safely delete an Observer after it is unsub...

random SemaphoreFullException error in SQLHelper class within a WCF service

I have an IIS hosted WCF Service which uses SqlHelper class from DAAB version 2.0 in the data layer Once in a while, it throws exception at this line of ExecuteReader (a static method): Microsoft.ApplicationBlocks.Data.SqlHelper.ExecuteReader() Type: System.Runtime.InteropServices.COMException Message: The handle is invalid. (Excepti...

ruby thread programming , ruby equivalent of java wait/notify/notifyAll

I would like to know what are ruby's alternatives to the Java methods : wait notify notifyAll Could you please post a small snippet or some links ? ...

Threading and GUI elements in C#

hi...i am trying to make a basic IRC client...but my problem is getting the text to display in a RTF box without it lagging i settled on using threading, and i want to update the RTF box in a thread, but i cant because it gives me errors about the RTF box element not being static? any insight? i will paste code if you guys want it ...

practice with threads in python

I know that Python has a global lock and i've read Glyph's explaination of python multithreading. But I still want to try it out. What I decided to do as an easy (conceptually) task was to do horizontal and vertical edge detection on a picture. Here's what's happening (pseudocode): for pixels in picture: apply sobel operator horiz...

Implementing a C++ threading Library in c++

I am a java programmer but currently working on the c++ language. Unlike java, the c++ does not define any threading utility. It is a little hard for me to implement a multi-threaded application in c++. Is there anyway someone can implement his own threading library using c++? Must you be able to grasp some concept of assembly language? ...

C : POSIX threads library test-suite

I'm working on a thread library which implement user level threads (i have something like pthread_setscope which works) and I'm looking for some set of tests to avoid writing one for every function I implement (mutexes, conditions, etc ...) Does anyone know something like that? ...

Pausing in between Retries of Network Connections

Im am writing an application for the JBOSS JEE-Server. I would like to have the DB-access code quite robust. Thus I have created retry loops so that the request won't fail because of temporary network problems. Now I would like the execution of the request to pause in between retries. The server thread has been spawned by a request to a...

Is it a good way to use java.util.concurrent.FutureTask ?

First of all, I must say that I am quite new to the API java.util.concurrent, so maybe what I am doing is completely wrong. What do I want to do? I have a Java application that basically runs 2 separate processing (called myFirstProcess, mySecondProcess), but these processing must be run at the same time. So, I tried to do that: publ...

Where does this deadlock hide?

Hi, I'm actually writing an MPI program. This is a basic client / server pattern. The server have a set of work to compute. The clients get subsets of this big set. Each client use several threads to compute the subset. I must be sure all the threads finished before requesting another subset to the server. The client is split into seve...

Can I use threads to carry out long-running jobs on IIS?

In an ASP.Net application, the user clicks a button on the webpage and this then instantiates an object on the server through the event handler and calls a method on the object. The method goes off to an external system to do stuff and this could take a while. So, what I would like to do is run that method call in another thread so I can...

Using TDD to drive out thread-safe code

What's a good way to leverage TDD to drive out thread-safe code? For example, say I have a factory method that utilizes lazy initialization to create only one instance of a class, and return it thereafter: private TextLineEncoder textLineEncoder; ... public ProtocolEncoder getEncoder() throws Exception { if(textLineEncoder == null)...

python, funny business with threads and IDEs?

Maybe i cant do what i want? I want to have 1 thread do w/e it wants and a 2nd thread to recv user input to set the quit flag. using this code i want to enter q anytime to quit or have it timeout after printing hey 6 times import sys import threading import time class MyThread ( threading.Thread ): def run (s): try: ...

Calling WCF service asyncronously in a loop

In my WPF client, I have a loop that calls a WCF service to update some records. When the loop is done, I display a message, "Update complete". I'm changing my WCF calls to async calls now. ServiceClient client = new ServiceClient(); client.UpdateRecordsCompleted +=new System.EventHandler<System.ComponentModel.AsyncCompletedEv...

Correct threads usage in Scheme (Bigloo)

Hi, I'm trying to write an application server in Scheme with Bigloo implementation. The code: (module server (library fthread) (main main)) (define *port-num* 8080) (define (main argv) (let* ((socket0 (make-server-socket *port-num*)) (ts (thread-start! (make-thread (lambda () (start-server socket0)))))) ...

ASP.NET Threading Not Working In Production

For some strange reason, I can't run any functions as a new thread in my production environment, even though it works fine locally and fine on the staging server, which has identical specs as the production server (Windows 2003, IIS 6) Here is my code: System.Threading.Thread th = new System.Threading.Thread(TestFunction); th.Start(); ...

How to tell if Invoke is required for a property?

If I am setting the Text property of a Form from a non-UI thread, then I need to use Invoke to avoid a cross-thread error. But, I can read the Text property without using Invoke. Is this safe? If I try to read the Handle property of a Form I get a cross-threading error. If I read the IsDisposed property of a Form it works fine. How can I...