multithreading

What kinds of concurrency/deadlock issues should one be aware of in Rails code?

I've just come to a realization about deadlocks - namely what they are - and I'm concerned about this issue affecting my Rails code. Are there any specific deadlock issues to watch out for while developing a Rails app? Have you ever encountered a deadlock in your Rails code - or is that even possible? (I'm not referring to database de...

Threading with Windows Forms

I've written a Windows Forms application in C#. When I run a separate thread containing a method that toggles the invisibility of a panel on my form, it works the first time but not the second. Why and how can I fix it? ...

WinForms: force GUI update from UI Thread

In WinForms, how do I force an immediate UI update from UI thread? What I'm doing is roughly: label.Text = "Please Wait..." try { SomewhatLongRunningOperation(); } catch(Exception e) { label.Text = "Error: " + e.Message; return; } label.Text = "Success!"; Label text does not get set to "Please Wait..." before the opera...

Waiting on multiple threads to complete in Java

Across the course of my programs execution a number of threads are started, the amount varies depending on user defined settings but they are all running the same method with different variables. In some situations, a clean up is required mid execution, part of this is stopping all the threads, I don't want them stop immediately though,...

How do I use System::Threading.Timer and also what are delegates invc++

Hi all i am trying to use System::Threading.Timer however it also involves delegates and the code posted on msdn is little cryptic -http://msdn.microsoft.com/en-us/library/system.threading.timercallback.aspx.it will be great if someone can explain it. ...

How do you wait for a Network Stream to have data to read?

I have a worker thread in my application that is responsible for three different things. Requests for two of the jobs turn up in Queues that I have written, the other job is activated when a request turns up on a Network stream. I would like my worker thread to wait when there is no work to be done. This is easy with the two Queues as th...

Max number of concurrent HttpWebRequests

Hello I'm stress testing a web app and have set up a windows test program that spins up a number of threads and sends out a web request on each one. Problem is I get the following output: 01/09/09 11:34:04 Starting new HTTP request on 10 01/09/09 11:34:04 Starting new HTTP request on 11 01/09/09 11:34:04 Starting new HTTP request on 1...

Hashmap and hashtable in multithreaded environment

I am really confused on how these 2 collections behave in multithreaded environment. Hash table is synchronized that means no 2 threads will be updating its value simultaneously right? ...

Java Multi threading synchronization problem?

Hi Guys, I think I have a synchronization problem...It may be too basic..Please help.. I have a thread the run method of which is below public void run() { while(true) { try { for (int i = 0; i < 100; i++) { buf.append(hello + (myint++)); } ...

Disposing a control by calling its own BeginInvoke()

Disposing a control from by calling its own BeginInvoke() is a good idea or bad idea? Or shall I use the parent control or something like that to accomplish this task? I'm using Invoke because I'm accessing the control form another thread. ...

Java thread start() without join() or interrupt() in servlet

I have a servlet filter that carries some logic and produces output before a request is served by it's primary page. I have a new need to send out the output a few seconds later than at the moment it is generated (with ~10s delay). Because of certain poor design choices made earlier I can't move the position of the filter just to have th...

Problem synchronizing QThreads

Apart from main thread, I've ThinkerThread object _thinker whose finished() signal is connected to main thread's slot: connect(&_thinker, SIGNAL(finished()), this, SLOT(autoMove())); The slot autoMove() causes _thinker to initialize and run again: _thinker.setState(/* set internal variables to run properly */); _thinker.start(); Th...

How to properly unit test calling UI method on another thread?

Having coded an extension method (based on http://stackoverflow.com/questions/723532/gui-update-when-starting-event-handler-class-on-separate-thread/723584#723584): public static class ControlExtensions { public static TResult InvokeEx<TControl, TResult> (this TControl control, ...

Properly locking a List<T> in MultiThreaded Scenarios?

Okay, I just can't get my head around multi-threading scenarios properly. Sorry for asking a similar question again, I'm just seeing many different "facts" around the internet. public static class MyClass { private static List<string> _myList = new List<string>; private static bool _record; public static void StartRecordin...

Is it safe to call CFRunLoopStop from another thread?

Hi all, The Mac build of my (mainly POSIX) application spawns a child thread that calls CFRunLoopRun() to do an event loop (to get network configuration change events from MacOS). When it's time to pack things up and go away, the main thread calls CFRunLoopStop() on the child thread's run-loop, at which point CFRunLoopRun() returns in...

Performance problems when scaling MSVC 2005's operator<< accross threads.

When looking at some of our logging I've noticed in the profiler that we were spending a lot of time in the operator<< formatting ints and such. It looks like there is a shared lock that is used whenever ostream::operator<< is called when formatting an int(and presumably doubles). Upon further investigation I've narrowed it down to this ...

A different requirement for a Splash Screen in winforms app

Hi there. Ok, I know this has been asked a million times before (and people also start off their StackOverflow question in the very same way XD), but I would like to know how to achieve the following: The application first launches a login box If the login is successful, then the splash screen must show (on a separate thread). While t...

Avoiding the woes of Invoke/BeginInvoke in cross-thread WinForm event handling?

I'm still plagued by background threading in a WinForm UI. Why? Here are some of the issues: Obviously the most important issue, I can not modify a Control unless I'm executing on the same thread that created it. As you know, Invoke, BeginInvoke, etc are not available until after a Control is created. Even after RequiresInvoke return...

Fork MySQL INSERT INTO (InnoDB)

Hello, I'm trying to insert about 500 million rows of garbage data into a database for testing. Right now I have a PHP script looping through a few SELECT/INSERT statements each inside a TRANSACTION -- clearly this isn't the best solution. The tables are InnoDB (row-level locking). I'm wondering if I (properly) fork the process, will ...

Is it possible to overload a thread using ISynchronizeInvoke.BeginInvoke()?

My problem is this: I have two threads, my UI thread, and a worker thread. My worker thread is running in a seperate class that gets instantiated by the form, which passes itself as an ISynchronizeInvoke to the worker class, which then uses Invoke on that interface to call it's events, which provide status updates to the UI for display....