multithreading

Testing twisted application - Load client

Hi, I've written a Twisted based server and I'd like to test it using twisted as well. But I'd like to write a load test starting a bunch of request at the same time. But I believe that I didn't get the concepts of Twisted, mainly client side, because I'm stucked with this problem: from twisted.internet import reactor, protocol f...

bug thread handling in java

public class Test extends Thread{ public void hello(String s){ System.out.println(s); } public void run(){ hello("I’mrunning..."); }//endofrun() public static void main(String [] args){ Test t=new Test(); System.out.println("always first"); t.start(); System.out.println("always second but...

Python MultiThreading With Urllib2 Issue

I can download multiple files quite fast with many threads at once but the problem is that after a few minutes it tends to slow down gradually to almost a full stop, I have no idea why. There's nothing wrong with my code that I can see and my RAM/CPU is fine.. The only thing I can think of is that urllib2 isn't handling the massive amoun...

Has anyone used SmartThreadPool of Ami Bar and can share his/her experience with it?

Dear ladies and sirs. I am looking into alternative ThreadPool implementations and have found the SmartThreadPool implementation by Ami Bar. It looks very interesting, so my question is whether anyone has actually used it and if so - please share the experience. Thanks. P.S. Our thread usage matches the one described as optimal by Am...

System.ArgumentNullException in System.Threading.Monitor.Enter

I've got a code like this: Some of our clients receiving "System.ArgumentNullException in System.Threading.Monitor.Enter" in the following code block: Public Class CheckStuff Private Shared SLock As New Object Public Sub GetIt() Synclock SLock DoSomething() End Synclock End Sub End Cl...

in Java, I can't assign values to variables while i'm in the run() function of a thread-extended class.

This is my code. As you see in the run method, I assign values to tStart, tEnd, tAround and wTime. But when the Thread ends, they still have the default values of -1. I try printing out their values while the run() is running, and I have the correct values. But they are not 'writing' those values back to the variables when the thread end...

Multithreaded server, bottleneck question

Hi, I am developing a multithread server which works nice so far - 1 separate thread for client accepting, threadpool for data reading and processing. Today I have added new thread for doing some stuff and sending messages to client every 500 ms (just 2-5 messages). I have noticed quite massive slowdown but Im not sure why - its separate...

Generic methods for checking if a library/API is thread safe

I received a library from an external developer in form of a well defined API(in C++ and Java). What can be some tests to check if the library is thread-safe ? ...

lock vs AcquireReader & writer locks

I have found possible slowdown in my app so I would have two questions: What is the real difference between simple locking on object and reader/writer locks? E.g. I have a collection of clients, that change quickly. For iterations should I use readerlock or the simple lock is enough? In order to decrease load, I have left iteration (on...

java Vector and thread safety

I'm wondering if this code will do any trouble: I have a vector that is shared among many threads. Every time a thread has to add/remove stuff from the vector I do it under a synchronized block. However, the main thread has a call: System.out.println("the vector's size: "+ vec.size()); which isn't synchronized. Should this cause tro...

Uninterruptable section

Hi I have a thread that does the following: 1) Do some work 2) Wait 3) Do some more work 4) Wait ... I want to (be able to) interrupt the thread while in one of the sleep sections but not in the work sections. The problem is that a work section might contain a smaller sleep section which might then catch an interrupt. So what I need...

Creating background/throttled thread

I'm trying to execute a long-running piece of code in a "background" thread and by "background" I mean low-priority thread not .NET background term. I created a thread, set its priority to Lowest and still 100% CPU is used if no other threads are running. The situation improves when I manually call Thread.Sleep(1) but I don't want to cha...

Joining a boost::thread instance in the destructor

I'm seeing an issue where a call to boost's thread->join in a destructor leads to a deadlock. I don't understand why, and I'm not too keen on keeping code that just works (and I don't understand why it does) in the project. Class declaration (I've stripped the run() method of try/catch for brevity: according to the boost thread documen...

Unhandled exceptions with Java scheduled executors

Hi, I have the following issue and I would like to know what exactly happens. I am using Java's ScheduledExecutorService to run a task every five minutes. It works very well. Executors completely changed the way I do thread programming in Java. Now, I browsed Java Doc for information about what would be the behavior in case the schedul...

Setting Form.Owner to a form from a different thread

Hi, My application (C#, VS2008) loads information from a database (SQL Server 2008 Express) over the network. During (possibly) longish waits, I want to have a 'Loading...' dialog box appear running on a different thread, but only if the operation takes more than a specific time period (say 500ms). So, I have so far got my loading for...

Is Meyers implementation of Singleton pattern thread safe ?

Is the following implementation, using lazy initialization, of Singleton (Meyers Singleton) thread safe? static Singleton& instance() { static Singleton s; return s; } If not, why and how to make it thread safe? ...

Thread.Join on multiple threads with timeout

I have an array of threads, and I want to Join them all with a timeout (i.e. see if they have all finished within a certain timeout). I'm looking for something equivalent to WaitForMultipleObjects or a way of passing the thread handles into WaitHandle.WaitAll, but I can't seem to find anything in the BCL that does what I want. I can of ...

Do Linux JVMs actually implement Thread priorities?

Wrote a quick Java proggy to spawn 10 threads with each priority and calculate pi (4*atan(1) method) with BigDecimals 500,000 times each, join on each thread and report the elapsed time for run method. Yeah, prob'ly not the best example, but keeping it basic. I'm aware of Bug4813310 It is non-trivial to do in C, but can we assume that...

VB.NET - Is this thread safe?

Let's say that I have a module that has a Queue in it. For other entities to Enqueue, they must go through a function: public sub InsertIntoQueue(Obj) MyQueue.Enqueue(Obj) end sub If I have multiple threads running and they want to call InsertIntoQueue(), is this considered thread safe? I am under the impression that there is on...

undefined reference to pthread_create in linux (c programming)

I'm interested in learning to write C programs which use threads. I picked up the following demo off the web from https://computing.llnl.gov/tutorials/pthreads/ #include <pthread.h> #include <stdio.h> #define NUM_THREADS 5 void *PrintHello(void *threadid) { long tid; tid = (long)threadid; printf("Hello World! It's me, thre...