multithreading

Start Thread with a given execution time

My main process calls an external library method. This method sometimes hangs. I can not fix the external library because another company is responsible for it. I want to use a Thread for the library calls with a defined execution timer. When the method call takes to long, the Thread with the Runnable in which the method call is placed ...

Threading TCP Server as proxy between connected user and unix socket.

I'm writing web application where I need to push data from server to the connected clients. This data can be send from any other script from web application. For example one user make some changes on the server and other users should be notified about that. So my idea is to use unix socket (path to socket based on user #ID) to send dat...

Effecient network server design examples, written in C

I am interested in learning how to write extremely efficient network server software and I don't mind getting my hands dirty with pointers, sockets and threading. I'm talking a server being able to handle thousands of concurrent connections. There is not much processing for each client, but a little. Do you know of any code examples for...

Does queuing threads impact non-thread safe objects in the same class?

If I spawn a thread with ThreadPool.QueueUserWorkItem and that thread does not reference the object that is not thread safe, would it compromise that non-thread safe object? [Edit] By not thread safe object, I mean a third party interface to a programmable logic controller that has no ability to open simultaneous connections or concurre...

Avoid Deadlock using Non-virtual Public Interface and Scoped Locks in C++

I've run into a problem which seems troubling to me. It seems I've found a situation that's easy enough to work-around, but that could lead to problems if a) I have a lapse in concentration while programming or b) somebody else starts implementing my interfaces and doesn't know how to handle this situation. Here's my basic setup: I've...

Trouble stopping Tomcat due to apparent threading issue..

With our Java webapp running on Apache Tomcat 6.0.18 on Ubuntu with Java 1.6.0_6, we can stop tomcat just fine. However, with the same war file deployed to a Apache Tomcat 6.0.18 on Red Hat Enterprise Linux with Java 1.6.0_13, calling /etc/init.d/tomcat6 stop does not stop Tomcat. I have not yet attempted using 1.6.0_6 on Red Hat to ...

Why temporary variable can stop client from removing event handler?

The following code snippet is from book Effective C#, public event AddMessageEventHandler Log; public void AddMsg ( int priority, string msg ) { // This idiom discussed below. AddMessageEventHandler l = Log; if ( l != null ) l ( null, new LoggerEventArgs( priority, msg ) ); } The AddMsg method showsthe proper wa...

In What Order are Semaphores Released in Windows?

Are semaphores released FIFO, random, or using some other algorithm? Does the algorithm avoid starvation? ...

Trouble Catching a WebException

The Problem We are occasionally getting a WebException that, as hard as we try we can not seem to catch. This results in an error showing up in the event log on the WebServer. Details We have an ASP.Net application that uses several webservices. One of the webservice methods can take a long time to run. To address this we use cachi...

Easiest way to trigger code at a given time in .NET

I'm looking for something nice and simple. For example: RunAfter(3, delegate() { z = 5; }); // run after 3 seconds FnThatTakes5Seconds(); In my cases I want to test some threading code and have something happen in the middle of another function call. ...

Why do my processes only consume 5% of the processors power?

Not sure if this is the appropriate place for this question, but it seems related to threading and system resources and all that. Why Does my Task Manager show that the System Idle Process is using 90%+ of the CPU power when I have 3 different processes going!?!? Is it because of I/O bottlenecks? For example, if I do an SVN checkout, ...

msemaphore on linux?

AIX (and HPUX if anyone cares) have a nice little feature called msemaphores that make it easy to synchronize granular pieces (e.g. records) of memory-mapped files shared by multiple processes. Is anyone aware of something comparable in linux? To be clear, the msemaphore functions are described by following the related links here. ...

debugging Intel's TBB containers

Recently we have started working with Intel's TBB and found that when debugging containers we cannot really watch the elements and their data. Is there a flag setting, a plugin or a tricky way to enable this? (maybe a script snipit for Visual to work with) ...

C#: Properly freeing thread

I've got an abstract class that spawns an infinitely-looping thread in its constructor. What's the best way to make sure this thread is aborted when the class is done being used? Should I implement IDisposable and simply this use this? public void Dispose() { this.myThread.Abort(); } I read that Abort() is evil. Should I instead ...

Best Practice for killing a JavaME 1.2 thread?

Question: I'm interested to know the best practice for killing a long standing operation that is running as a background thread (lets call this thread WorkerThread) in Java 1.2. Scenario Specifically, I'm developing an application for Blackberry devices whereby I make a HTTP connection. Big picture: a URL request if forwarded to a back...

Determine when to close a sound-playing thread in Java

I am playing of a sound-file in Java, and is looking for a simple way to determine when the sound-file has finished playing so I can kill the thread. Is there a simple way to accomplish this? ...

How can I get a Future<MyObject> without using ExecutorService ?

I would really like to do something like this: Callable<MyObject> myCallable = .... Future<MyObject> = new Thread( myCallable).start(); I basically want to start a single long-running task that runs in parallel with my main task, and I do not want pooling or thread re-use. The Executors stuff seems to be very pooling oriented and it...

Server.Transfer and System.Threading.ThreadAbortException

See http://support.microsoft.com/kb/312629/EN-US/ I am using reponse.direct in my app as well and I am not getting the exception. The workaround that the knowledge base article suggests (Server.Execute) does not work for me. I am getting lots of javascript exceptions from the Ajax Toolkit on the target page if I use Server.Execute, and ...

How to debug ConcurrentModificationException?

I encountered ConcurrentModificationException and by looking at it I can't see the reason why it's happening; the area throwing the exception and all the places modifying the collection are surrounded by synchronized (this.locks.get(id)) { ... } // locks is a HashMap<String, Object>; I tried to catch the the pesky thread but all I ...

Restore of data replicated with erasure-coding

I need your help on the design of the restore-procedure in a backup system I'm building. The prerequisites are the following: A restore can be made of one or several files. A file consists of 1 or more data-blocks (on average 16mb in size, minimum 4mb maximum 64mb). A data-block is replicated using erasure coding into replication-bloc...