multithreading

Getting the output of a Thread

What do you think is the best way for obtaining the results of the work of a thread? Imagine a Thread wich does some calculations, how do you warn the main program the calculations are done? You could poll every X milliseconds for some public variable called "job finished" or something by the way, but then you'll receive the results lat...

best way to run multi-threaded nunit tests

I currently trying to find a solution, how to ensure that a test fails if an exception occurs in a thread which is spawn by the test method. I DON'T want to start a discussion about more than one thread in a unit test. => "unit test".Replace("unit","integration"); I already read a lot of threads in several forums, I know about CrossThr...

Future.get() and InterruptedException Asynchronous threading

Im using asynchronous threading in my application WITH httpClient. I make a call using the Future Api like so mStrResults = (String) rssFuture.get(); this call attempts to retrieve an html string returned from my Callable httpClient call() method. What i want to do however is ensure that the get method does not wait too long while ...

_endthreadex(0) hangs

I have some code which I did not originally create that uses _beginthreadex and _endthreadex. For some reason, when it calls _endthreadex(0), the call just hangs and never returns. Any ideas as to what would normally cause this call to hang? ...

How can I detect a ThreadAbortException in a finally block? (.NET)

I have some critical logic in a finally block (with an empty try block), because I want to guarantee that the code gets executed even if the thread is aborted. However, I'd also like to detect the ThreadAbortException. I've found that wrapping my critical try/finally block in a try/catch does not catch the ThreadAbortException. Is there ...

How do Mac OS X processes and threads differ?

In my Mac OS X Activity monitor it lists each "process" id for each application. It links several processes to a single thread, for instance iTunes and Finder are currently both listed under thread 7. The way I learned about threads and processes would lead me to think that this should be the other way around. I learned that a process ha...

Automatically terminating non essential threads in C#

I have an object in C# on which I need to execute a method on a regular basis. I would like this method to be executed only when other people are using my object, as soon as people stop using my object I would like this background operation to stop. So here is a simple example is this (which is broken): class Fish { public Fish()...

Is SQLite thread safe under this situation?

I require database access operations from several threads, through a singleton object, which holds a database connection. I read from SQLite3's website, saying that 'an sqlite3 structure could only be used in the same thread that called sqlite3_open() to create it. You could not open a database in one thread then pass the handle off to a...

Does thread-safety of sqlite3 mean different threads can modify the same table of a database concurrently?

Thank you! ...

BlackBerry threading model

I've read a lot of comments mention in passing that the BlackBerry threading model deviates from the Java standard and can cause issues, but no amount of googling has enlightened me on what this means exactly. I've been developing a fairly large business application for the BlackBerry and, although I don't really have any previous exper...

be notified when all background threadpool threads are finished

Hello, comrades. I have a scenario when I start 3..10 threads with ThreadPool. Each thread does its job and returns to the ThreadPool. What are possible options to be notified in main thread when all background threads have finished? Currently I'm using a homegrown method with incrementing a variable for each of created threads and dec...

How can I handle multiple sockets within a Perl daemon with large memory usage?

I have created a client-server program with Perl using IO::Socket::INET. I access server through CGI based site. My server program will run as daemon and will accept multiple simultaneous connections. My server process consumes about 100MB of memory space (9 large arrays, many arrays...). I want these hashes to reside in memory and shar...

Is it OK to use Pulse & Wait? Or it is evil and a cause of write-only code?

Monitor.Pulse/All and Monitor.Wait are useful methods, but I'm getting complaints that when using them in large quantities (I have a DSL designer that spits them out by the dozen), the resulting code becomes unreadable. What do you think? ...

Multicore + Hyperthreading - how are threads distributed?

I was reading a review of the new Intel Atom 330, where they noted that Task Manager shows 4 cores - two physical cores, plus two more simulated by Hyperthreading. Suppose you have a program with two threads. Suppose also that these are the only threads doing any work on the PC, everything else is idle. What is the probability that the ...

TDD Test Refactoring to support MultiThreading

So I'm a newbie to TDD, and I successfully created a nice little sample app using the MVP pattern. The major problem to my current solution is that its blocking the UI thread, So I was trying to setup the Presenter to use the SynchronizationContext.Current, but when I run my tests the SynchronizationContext.Current is null. Presenter B...

In C#, wait on the mainthread while continuing to process UI updates? (.NET 2.0 CF)

I want to otherwise block code execution on the main thread while still allowing UI changes to be displayed. I tried to come up with a simplified example version of what I'm trying to do; and this is the best I could come up with. Obviously it doesn't demonstrate the behavior I'm wanting or I wouldn't be posting the question. I just hop...

How low do you go before something gets thread-safe by itself?

Hi all.. I've been thinking, just how deep into everything do you have to go before something is automatically thread-safe? Quick example: int dat = 0; void SetInt(int data) { dat = data; } .. Would this method be considered threadsafe? I ussually wrap all my set-methods in mutex'es, just to be sure, but everytime I do so I can'...

Thread safety and `const`

How does const (pointers, references and member functions) help with thread safety in C++? ...

How many simultaneous threads in an application is a lot?

5, 100, 1000? I guess, "it depends", but on what? What is common in applications that run as server daemons / services? What are hard limits? Given that the machine can handle the overall workload, how do I determine at how many threads the overhead starts to have an impact on performance? What are important differences between OS's...

C# How do I run a simple bit of code in a new thread?

I have a bit of code that I need to run in a different thread than the GUI as it currently causes the form to freeze whilst the code runs (10 seconds or so). I have never created a new thread before so I'm after a basic example (as simple as possible) of how to do this in C# .Net 2.0. Could someone please post an example? Many thanks ...