multithreading

Handling an exception in another thread

What is the "correct" way of detecting and handling an exception in another thread in Python, when the code in that other thread is not under your control? For instance, say you set a function that requires 2 parameters as the target of the threading.Thread object, but at runtime attempt to pass it 3. The Thread module will throw an exc...

Java: Large collection and concurrent threads

Hello. I am facing this issue: I have lots of threads (1024) who access one large collection - Vector. Question: is it possible to do something about it which would allow me to do concurrent actions on it without having to synchronize everything (since that takes time)? What I mean, is something like Mysql database works, you don't have...

Objective C: How to kill a thread while in another thread in Objective-C?

I was trying to set up a multi thread app. One of the threads is working as background to get some data transfer. Right now this thread automatically kill itself after it's job done. Somehow I need to kill this thread in another thread in order stop its job immediately. Are there any api or method for making this happen? ...

Shutting down worker threads gracefully

I don't understand why in this implementation stopped is not volatile - If a different thread updates this will it be reflected correctly? Secondly is testing (!Stopping) atomic? using System; using System.Threading; /// <summary> /// Skeleton for a worker thread. Another thread would typically set up /// an instance with some work t...

Shared objects and multithreading issues. Should I care ?

I have a windows service hosting several WCF services. In my windows service I have couple objects with singleton behavior. This objects are accessible thru the WCF services from outside. A call can put a value into the objects and another call can retrieve this value. Should I care about multithreading issues? I'm not starting any thre...

Asynchronous control validation

I need to validate a control input on losing focus. Normally I'd use the Validating event. However this process involves checking the entered data against a local database of over 280,000 postal codes. I'd like for this validation to occur asynchronously since there is no requirement for the user to wait for it before they can enter the ...

Log4J - SiftingAppender-like functionality

I work in a project that uses Log4J. One of the requirement is to create a separate log file for each thread; this itself was a odd issue, somewhat sorted by creating a new FileAppender on the fly and attaching it to the Logger instance. Logger logger = Logger.getLogger(<thread dependent string>); FileAppender appender = new FileAppende...

Thread deadlock blocked on Hibernate transaction

I have one process which creates a database entity and then launches a second process. It then waits on the second process to find and update the database entity before completing its processing, and thereby committing the database entity. The trouble seems to be that since the initial process which performed the entity creation has no...

Understanding multithreading, delegates and static

Okay, I'm trying to write a program that will scan a bunch of words to match against a set of letters. I want all words displayed that contain the letters entered by the user and I want these words displayed while the program is still searching. Therefore, I have to split the search onto its own thread, separate from the UI thread. Ea...

C#: Invoke Event from Locked Block

I have usually heard that it is a good idea to unlock any locks before calling event listeners to avoid deadlock. However, since the lock {} block is reentrant by the same thread in C#, is it OK to call events from a locked block or do I need to make a copy of the relevant state data and invoke the event outside the lock block? If not,...

Thread Synchronization and Thread Pausing\Resuming

Hi, I am trying to send the files from local to FTP, for that I am locking the TCPClient before sending the file. And that file sending is doing in another thread. So that the main thread doesn't affected. As when I try to use the locked TCPClient before Unlocking it, it hangs. So how should I proceed, so that at the same time I can sen...

How to suspend and resume thread?

Hi, I need to suspend the current thread if there exists a high priority thread, How can I do that.I need to suspend that thread and execute the new high priority thread first then after it accomplished, then resume earlier one. ...

WPF - Wait Animation on a seperate thread?

(Note: I have seen this question and it uses a cursor not an animation.) I have a wait animation (that I did not make but found on the internet). I want to show it while my app is doing some processing. However, it gets stuck while my app is processing. Is there a way to make it keep going smooth? I usually think of a thread for t...

Difference between a "coroutine" and a "thread"?

What are the differences between a "coroutine" and a "thread"? ...

Python, Threads, the GIL, and C++

Is there some way to make boost::python control the Python GIL for every interaction with python? I am writing a project with boost::python. I am trying to write a C++ wrapper for an external library, and control the C++ library with python scripts. I cannot change the external library, only my wrapper program. (I am writing a functi...

do sem_wating threads cause more switching

I have several threads which act as backup for the main one spending most of their life blocked by sem_wait(). Is it OK to keep them or is it better to spawn new threads only when they need to do actual work? Does kernel switch to threads waiting on sem_wait() and "waste" CPU cycles? Thanks. ...

Best Way to send message to thread c# .net (inter-thread communication)

Hi , What is the most efficient and fastest way to send message to a thread(not process) that run in while(1) loop in c#/.net : 1) Using a synchronized queue (such in http://www.geekscafe.net/post/Blocking-Queues-Threade28099s-Communication-in-C.aspx) 2) Running a message loop Using Application.Run of systems winforms in the thread co...

Why doesnt my console close until a 'window' event happens?

I am curious. I run this in the background and i know when its done when i see the console disappear. I can check the status by clicking on it and see the output. Then i decided to add a quit button. It no longer disappears when done (it can stay alive for minutes or hours) but once i click on the console it ends. Why? I wrote this to s...

Checking whether SendAsync has finished sending

As in the simplified code below, is checking that SendAsync() has finished transmitting all intended bytes in the buffer the correct thing to do? Or is that redundant? This is for a TCP connection socket. I am particularly concerned with having to issue a second sub-call to SendAsync() inside ProcessSend(). For example, if I had multip...

class NSCFNumber autoreleased with no pool in place - just leaking

Hi everyone, I am new to C++ and have just started to work on a project using threading. Currently my project involves the OpenGL and OpenCV libraries, and in the process of coding I encountered the following error : Current language: auto; currently c++ 2009-12-21 14:54:49.438 3DTestApp[3210:7803] *** _NSAutoreleaseNoPool(): Objec...