multithreading

Efficient Number of Threads

I want to optimize my application number of threads. Almost all of them have IO beside CPU usage in an equal value. How much is the efficient number of threads when there are no other applications running in system. I want the answer for Windows and under JVM. ...

interlock vs mutex, scale-up issues

Hi, I am facing the problem, that I have an C# (.NET) object shared among some threads. A thread might replace the object with another one. The threads are waken up from a TCP/IP connection using the Asynchronous framework. Sequence: Threads (waiting for connection) -> Asynchronous Callback -> Do something thread-safe -> Access the sh...

Java volatile variable question

Reading this DZone article about Java concurrency I was wondering if the following code: private volatile List list; private final Lock lock = new ReentrantLock(); public void update(List newList) { ImmutableList l = new ImmutableList().addAll(newList); lock.lock(); list = l; lock.unlock(); ...

Silverlight image Uploader -- help!!

The following is the main body of code for an image resizer/compressor/uploader. This is my first silverlight project, and I am having trouble with the threading and gui updating as well as the webclient part, which does not function.The resizing and resampling seem to perform to my knowledge. The problem is the gui updating and uploadin...

App doesn't exit when main window is closed

I keep having this problem, solving it, and then when I implement new code it comes back again. It's driving me crazy! What I finally found was that if you instantiate a Window of any kind, even if you never call Show() or ShowDialog(), when you close your application, it will not terminate. So now I make sure to call Close() when app...

Using pThreads, is it possible to write a function that can detect what thread it's being called from?

This is the usage case: Log(char* s); // prints out a log message Now: Log("hello world\n"); // called from Thread1 Desired output: Thread1: hello world Now: Log("hello world\n"); // called from Thread2 Desired output: Thread2: hello world I can have a map that maps thread pids to strings. What I need however, is a functio...

What is api interception? when is it used? how to implement it in C++

What is API interception When is it used How to implement it in C++ ...

thread safe containers in arrays

Hi, can anyone please explain, whether accessing an array by multiple threads, where each thread is working on a different element of the array. so there are n elements, and n threads ==> the nth thread is working on the nth element of the array? can any one be kind enough to explain if this is safe or not? and why or why not? thank...

Using .NET BackgroundWorker class in console app

I am relatively new to .NET programming and multithreading in general, and was wondering if it is ok to use .NET provided BackgroundWorker to spawn off worker threads to do some work in a console application? From the various documentation online, I see that intent for this class is more for UI oriented applications, where you want to do...

Unlocking a lock from a thread which doesn't own it, or redesigning to avoid this?

I have an archive object which manages various byte arrays and hands out InputStreams and OutputStreams for reading and writing them. Each byte array has an associated ReentrantReadWriteLock. The constructor of the subclass of InputStream which the archive produces acquires the lock for the relevant data, while close() releases the loc...

Problem with multiple scripts and Lua Threads

When I have two scripts with the same function names and arguments run in different threads with SUPPOSEDLY different environments, the second thread ends up overwriting the definitions of the first and the first thread's state gets garbage collected! // My thread instancing function lua_State* LuaInstance::RunInstance(const std::string...

Running multiple threads, starting new one as another finishes.

I have an application that has many cases. Each case has many multipage tif files. I need to covert the tf files to pdf file. Since there are so many file, I thought I could thread the conversion process. I'm currently limiting the process to ten conversions at a time (i.e ten treads). When one conversion completes, another should s...

Delphi Thread freeze

I coding a service application that have two threads. First thread, show a form with label. Second thread, query ADO. First thread always freezing with Hourglass cursor and no label caption. Please help. ...

*** glibc detected *** double free or corruption (fasttop):

A call to clear on a QByteArray generates the following exception: * glibc detected * /home/yan/FPS2/FPS2: double free or corruption (fasttop): 0 ?? 1 ?? 2 free 3 QByteArray::clear() 4 FPSengine::getDatagrams 5 FPSengine::xmitData 6 FPSengine::getData 7 threadDatalog::run 8 ?? 9 start_thread 10 clone 11 ?? 0 is this a qt ...

Why doesn't super(Thread, self).__init__() work for a threading.Thread subclass?

Hi, Small question. Every object I know of in python can take care of its base class initialization by calling super(BaseClass, self).__init__() This doesn't seem to be the case with a subclass of threading.Thread, since if I try this in SubClass.__init__(), I get: RuntimeError: thread.__init__() not called What gives? I looked ...

Is it necessary to explicitly stop all threads prior to exiting a Win32 application?

I have a Win32 native VC++ application that upon entering WinMain() starts a separate thread, then does some useful job while that other thread is running, then simply exits WinMain() - the other thread is not explicitly stopped. This blog post says that a .NET application will not terminate in this case since the other thread is still ...

cygwin multi-threaded c++ debugging with netbeans

When I debug my program with netbeans using cygwin's g++, when it receives a sigabrt, I can't see my code anywhere in the call stack of any of the threads. Most of them are at ntdll!RtlEnableEaryCriticalSectionEventCreation() and one in RaiseException(). The problem is that after these there are only either some win32 functions without a...

XMPP4R Callbacks dont seem to work

Im using xmpp4r and trying to get the hang of a basic chat feature that I wish to implement later in my Rails app. My fundamentals on Ruby Threads is still a bit shaky so I would appreciate any help on this. Though I register the callback i dont get a response from my gmail account. I am able to send a message but my ruby program termi...

Thread safe instantiation of a singleton

Which one synchronization method to use to ensure a singleton remains a singleton? +(Foo*)sharedInstance { @synchronized(self) { if (nil == _sharedInstance) { _sharedInstance = [[Foo alloc] init]; ... } } return _sharedInstance; } or using a mutex? #import <pthread.h> static pthread_mu...

WCF service with ConcurrencyMode.Multiple and InstanceContextMode.Single behavior and multithreading safety

I have a service configured with following attributes [ServiceBehavior(ConcurrencyMode = ConcurrencyMode.Multiple, InstanceContextMode = InstanceContextMode.Single)] public class UserService : IUserServiceContract {} Should I use in this scenario locking mechanism for methods implemented in the service? If yes, is this the proper im...