multithreading

How to profile multi-threaded C++ application on Linux?

I used to do all my Linux profiling with gprof. However, with my multi-threaded application, it's output appears to be inconsistent. Now, I dug this up: http://sam.zoy.org/writings/programming/gprof.html However, it's from a long time ago and in my gprof output, it appears my gprof is listing functions used by non-main threads. So, ...

Delegate within a delegate in VB.NET.

I am trying to write a VB.NET alternative to a C# anonymous function. I wish to call Threading.SynchronizationContext.Current.Send which expects a delegate of type Threading.SendOrPostCallback to be passed to it. The background is here, but because I wish to both pass in a string to MessageBox.Show and also capture the DialogResult I ne...

how to print correctly the handling thread on Windows?

Hi, Could someone please tell us on how to print correctly the handling thread in windows? Actually I tried several ways but it doesn't return the right number as in Unix-variant, as such e.g.: cout << " with thread " << pthread_self << endl; cout << " with thread " << pthread_self().p << endl; Thanks for your replies: ...

How to use multithreading in c# for sending .........

How to use multithreading in c# for sending the SMS to multiple person at a times? Use must of multithread. means must execute sms sending code/process independently at a time. (synchronisely) how can i do this ? please guide. ...

Using SetThreadAffinityMask function imported from kernel32.dll in C # code.

I am trying to set Thread Affinity using SetThreadAffinityMask function imported from kernel32.dll in C # code of mine. This is how I import SetThreadAffinityMask function from "kernel32.dll" in my C# .net code [DllImport("kernel32.dll")] static extern IntPtr SetThreadAffinityMask(IntPtr hThread, IntPtr dwThreadAffinityMask); I a...

Java Design questions

Suppose there is a System A which gives some output. This output is used as input by system B. The rate at which System A produces is faster than the rate at which system B consumes it. How can we implement this? The System A sends video at 10mbps where system b can take up only 4mbps.how we can implement this.Also there should be conti...

multithreading and sever.execute

hi folks, I have this scenerio where i have to get some records, enumerate them, and send emails to the customers using a new thread in the appliction. Here is the code. foreach (BookingDetail b in bookings) { StringWriter sw = new StringWriter(); context.Server.("Emails/FeedbackEmail.aspx?BookingDetailI...

ThreadQueue problems in "Accelerated C# 2008"

Example for threading queue book "Accelerated C# 2008" (CrudeThreadPool class) not work correctly. If I insert long job in WorkFunction() on 2-processor machine executing for next task don't run before first is over. How to solve this problem? I want to load the processor to 100 percent public class CrudeThreadPool { static readonl...

How best to notify my Delphi App from a Windows callback

I'm using the Multimedia timer in Delphi and this works great for quite accurate callbacks (compared to a traditional TTimer). However the callback is from another thread. I dont have a convenient form to use for PostMessage() or a message based means of notifying my app that the callback has happened - I just have a class. I'm happy wit...

Core dump of a multithreaded program

Hi, i have regularly worked with single threaded programs. i never saw a multithreded program crashing since i havent worked on any. is there any difference between both the core dumps? is there any additional information provided in the core dump of a multithreaded program when compared to a single threaded program? ...

Java synchronized seems ignored

Hi, I've got the following code, which I expected to deadlock after printing out "Main: pre-sync". But it looks like synchronized doesn't do what I expect it to. What happens here? import java.util.*; public class deadtest { public static class waiter implements Runnable { Object obj; public waiter(Object obj) { ...

Thread resource sharing

I'm struggling with multi-threaded programming... I have an application that talks to an external device via a CAN to USB module. I've got the application talking on the CAN bus just fine, but there is a requirement for the application to transmit a "heartbeat" message every second. This sounds like a perfect time to use threads, so I ...

java.util.concurrent.ThreadPoolExecutor strange logic

Look ath this method of ThreadPoolExcecutor: public void execute(Runnable command) { ... if (runState == RUNNING && workQueue.offer(command)) { if (runState != RUNNING || poolSize == 0) ensureQueuedTaskHandled(command); } ... } It check that runState is RUNNING and then the oposite...

How can I remove a JPanel from a JFrame?

Recently I asked here how to add a new JPanel to JFrame. The answer helped me to get a working code. But not I have a related question: "How can I remove an old JPanel". I need that because of the following problem. A new JPanel appears appears when I want (either time limit is exceeded or user press the "Submit" button). But in several...

Using ThreadPool.QueueUserWorkItem - thread unexpectedly exits

I have the following method: public void PutFile(string ID, Stream content) { try { ThreadPool.QueueUserWorkItem(o => putFileWorker(ID, content)); } catch (Exception ex) { OnPutFileError(this, new ExceptionEventArgs { Exception = ex }); } } The putFil...

Subclassing a window from a thread in c#

I'm creating a thread that looks for a window. When it finds the window, it overrides its windowproc, and handles WM_COMMAND and WM_CLOSE. Here's the code that looks for the window and subclasses it: public void DetectFileDialogProc() { Window fileDialog = null; // try to find the dialog twice, with a delay of 500 ms each time ...

WPF update binding in a background thread

I have a control that has its data bound to a standard ObservableCollection, and I have a background task that calls a service to get more data. I want to, then, update my backing data behind my control, while displaying a "please wait" dialog, but when I add the new items to the collection, the UI thread locks up while it re-binds and ...

New thread per client connection in socket server?

I am trying to optimize multiple connections per time to a TCP socket server. Is it considered good practice, or even rational to initiate a new thread in the listening server every time I receive a connection request? At what time should I begin to worry about a server based on this infrastructure? What is the maximum no of background...

synchronize sql connection in multithreading in .NET

I am using multi threading concept to run some process. this process uses the sql connection object to get the data from database.This object is in another class. how to synchronize the sql connection while using multithreading? ...

WPF dispatcher/threading issue

Hello I have a problem in my code and I am not able to fix it at all. private static void SetupImages(object o) { int i = (int)o; BitmapImage bi = GetBitmapObject(i); img = new System.Windows.Controls.Image();//declared as static outside img.Source = bi;//crash here img.Stretch = Stretch.Uni...