multithreading

rails Rake and mysql ssh port forwarding.

Hello, I need to create a rake task to do some active record operations via a ssh tunnel. The rake task is run on a remote windows machine so I would like to keep things in ruby. This is my latest attempt. desc "Syncronizes the tablets DB with the Server" task(:sync => :environment) do require 'rubygems' require...

Execute some operation after the thread is completed

Greetings, everyone! I have a class (say, "Switcher" ) that executes some very-very long operation and notifies its listener, that operation is complete. The operation is long, and I isolate actual switching into separate thread: class Switcher { public: // this is what other users call: void StartSwitching() { // a...

Desktop Multithreading UI sample application for .net

Are there any good sample UI applications which illustrate multi threading best practices in .net? The scenario I am thinking of is a graphically rich scorecard where the kpi's are being updated from several different sources and threads. Although I am interested in WPF a Winforms sample application would I believe serve just as well ...

Python, Ruby, Haskell - Do they provide true multithreading?

We are planning to write a highly concurrent application in any of the Very-High Level programming languages. 1) Do Python, Ruby, or Haskell support true multithreading? 2) If a program contains threads, will a Virtual Machine automatically assign work to multiple cores (or to physical CPUs if there is more than 1 CPU on the mainboard...

How is the thread-pool handled when using System.Timer objects in multiple threads?

Ok, I know an object of System.Timer executed in the thread-pool, rather than in the UI thread. I also know that the System.Timer is thread-safe. Say I have a collection of System.Timer objects. I can have all of them run and (unless i'm mistaken) they'll actually execute in the thread-pool. Say I instead create a collection of thre...

Problem with background worker

Say I have the following class/Form (semi psuedo): public partial class X : Form { private DataTable dt; private BackgroundWorker bg; public X() { dt.Columns.Add("A"); dt.Columns.Add("B"); dt.Columns.Add("C"); } private void button_Click(...) { bg = new BackgroundWorker(); ...

Thread safe sql transaction, how to lock a specific row during a transaction ?

I have a procedure like this: create procedure Checkout @Foo nvarchar(20), @cost float as begin transaction declare @Bar nvarchar(20); select @Bar = Bar from oFoo where Foo = @Foo; update Foo set gold = gold - @cost where name = @Foo; update Bar set gold = gold + @cost where name = @Bar; delete from oFoo where @Foo = Foo; commit tra...

Is waiting for an event that will never trigger a deadlock?

A deadlock normally means that thread (or process) A is waiting for thread B, and at the same time thread B is waiting for thread A. Currently I encountered a similar situation in our application. Thread A is waiting for an event to be set by thread B. However, thread B is not waiting for thread A, it just won't set the event (no matte...

How to pass sockets created to another Java Process

Hi; We have an application which creates many sockets which belongs to its thread, By design if this application somehow fails, all threads stop which is not wanted. So to overcome this issue, each thread must be separated from the main application, if one of the threads fails, the other ones should be running. One thing in our mind is t...

Java sync games: synchronized && wait && notify

I'm coming from .NET world, and unfortunately looking Java source with .NET's eyes. Following code is from Android Apps (though not Android specific at all): private class Worker implements Runnable { private final Object mLock = new Object(); private Looper mLooper; Worker(String name) { Thread...

Number of Threads in Java

How can i see the number of threads in a java? ...

thread synchronization - delicate issue

let's i have this loop : static a; for (static int i=0; i<10; i++) { a++; ///// point A } to this loop 2 threads enters... i'm not sure about something.... what will happen in case thread1 gets into POINT A , stay there, while THREAD2 gets into the loop 10 times, but after the 10'th loop after incrementing i's value to 10, befo...

Does Interlocked.CompareExchange(double,double,double) work in 32 bit OS?

I'm maintaining a high performance class that can be operated on by multiple threads. Many of the fields are volatile ints, and as it turns out I need to upgrade one of those to a double. I'm curious if there is a lock free way to do this, and was wondering if the Interlocked.CompareExchange(double, double, double) works as advertised ...

How can I detect if a thread has windows handles?

How can I programmatically detect if a thread has windows handles on it for a given process? spy++ gives me this information but I need to do it programmatically. I need to do this in C#, however the .net diagnostics libs don't give me this information. I imagine spy++ is using some windows api call that I don't know about. I have ac...

Simple background thread restarting in .NET

I'm working on an WPF application that has a few threads that are processing information in the background. If one of the threads crashes, it brings down the app. I'm going to correct that by wrapping the function passed to threadstart in a try/catch. However, I was wondering if I could do one better. It should be possible to write a si...

Threading: does c# have an equivalent of the Java Runnable interface?

Does c# have an equivalent of the Java Runnable interface? If not how could this be implemented or is it simply not needed? thanks. ...

Differing behavior when starting a thread: ParameterizedThreadStart vs. Anonymous Delegate. Why does it matter?

When I run the code below the output is "DelegateDisplayIt", typically repeated 1-4 times. I've run this code probably 100 times, and not once has the output ever been "ParameterizedDisplayIt". So it seems the manner in which the thread is created and subsequently started affects how the parameter is passed. When creating a new thread wi...

Running Legacy, Non-Reentrant Code on a Background Thread in .NET

I'm in needed of a thread worker in my .NET application - .NET has several classes such as thread pools etc., but I can't find anything that runs on a single thread, which is a requirement in my case. So I've had a go a writing one myself, but these things are notoriously tricky, I'm sure I've got something wrong. Can anyone improve it ...

Invalid cross-thread access issue

I have two ViewModel classes : PersonViewModel and PersonSearchListViewModel. One of the fields PersonViewModel implements is a profile image that is downloaded via WCF(cached locally in isolated storage). The PersonSearchListViewModel is a container class that holds a list of Persons. Since loading images is relatively heavy, PersonSear...

How to catch exception from thread?

I am using a free .net telnet component (De.Mud.Telnet), which has several asynchronous methods you can call, and the component fires events when things happen. My problem is that the component is throwing an exception and I don't know how to catch it. There's no exception event, and the exception doesn't get thrown by my method call. ...