multithreading

Does Console.WriteLine block?

Does Console.WriteLine block until the output has been written or does it return immediately? If it does block is there a method of writing asynchronous output to the Console? ...

What's going on in this program, and, more importantly, why?

Please help me understand this program's execution and what concepts apply here in the larger sense? An illustration which explains thread(s)/stack(s) creations and destruction would be helpful. class Joining { static Thread createThread(final int i, final Thread t1) { Thread t2 = new Thread() { public void run...

Loading Windows form with over 200 controls

My form has over 200 control(s)! It takes about 7 seconds to load the form and bind the controls. I've traced the application with some performance profilers , but I didn't find anything with HOT flag except the constructor's of form. I would like to know that is it possible to call InitializeComponent method with sth like backgroundWo...

Serial Task Executor; is this thread safe?

I have a class that I've created to allow asynchronous sequential execution of tasks, using the ThreadPool as the means of execution. The idea is that I'll have multiple instances running serial tasks in the background, but I don't want to have a separate dedicated Thread for each instance. What I'd like to check is whether this class ...

placeholder for storing temp values in c# thread context

I want to store some info (key value pair) in a c# thread context or similar ( just like httpcontext for a web request ). I want to be able to store this info (key value pair) somewhere in thread context ( or something similar) so that my code can always read these values from the current thread its running under. In my appliation i ha...

pthreads: If I increment a global from two different threads, can there be sync issues?

Hi all, Suppose I have two threads A and B that are both incrementing a ~global~ variable "count". Each thread runs a for loop like this one: for(int i=0; i<1000; i++) count++; //alternatively, count = count + 1; i.e. each thread increments count 1000 times, and let's say count starts at 0. Can there be sync issues in this case? O...

How can I create a thread in unix?

How can one create a thread in unix programming? What is difference between forking and threading? Is threading more useful than forking? ...

Is the AutoResetEvent type an appropriate choice for an atomic switch?

Suppose I am processing a large amount of incoming data from multiple threads. I may want for this data to act as a trigger for a specific action when certain criteria are met. However, the action is not reentrant; so the same trigger being fired twice in rapid succession should only cause the action to run once. Using a simple bool fla...

Why need a null mutex?

Why would one need a mutex object where the Acquire and release methods just return 0? I am studying the ACE framework and it has a Null_Mutex class, and I was wondering how it would come to use. class Null_Mutex { public: Null_Mutex (void) {} ˜Null_Mutex (void) {} int remove (void) { return 0; } int acquire (void) const { return 0; } ...

What important difference exists between Monitor.TryEnter(object) And Monitor.TryEnter(object, ref bool)?

It seems that these code snippets ought to behave identically: 1: Monitor.TryEnter(object) if (Monitor.TryEnter(lockObject)) { try { DoSomething(); } finally { Monitor.Exit(lockObject); } } 2: Monitor.TryEnter(object, ref bool) - introduced in .NET 4.0 bool lockAcquired; try { Monitor.TryE...

Thread Handling in android

Hi all, What are the plans to handle thread locks that might occur when two modules access the GPS thread concurrently.. if possible please provide some resources or snippet Thanks in advance ...

Threads synchronization in Java

I have a scenario like.... There are four threads named as Thread1, Thread2, Thread3 and Thread4. and there is one counter variable. And I want output as below Thread1 : value of counter variable is = 0 Thread2 : value of counter variable is = 1 Thread3 : value of counter variable is = 2 Thread4 : value of counter variable is = 3 Threa...

Outlook Addin Deployment Thread

Hi, i am developing a outlook addin in c#, heres my startup: private void ThisAddIn_Startup(object sender, System.EventArgs e) { //adds the new issueTopMenu //Search the menu and delete if found RemoveMenubar(); //adds the panel AddPanelToExplorer(); //Method to create new menu ...

Threads application terminates unexpectedly

I have little scraping application and trying to add multithreading to it. Here is code (MyMech is WWW::Mechanize subclass used to process HTTP errors): #!/usr/bin/perl use strict; use MyMech; use File::Basename; use File::Path; use HTML::Entities; use threads; use threads::shared; use Thread::Queue; use List::Util qw( max sum ); my $...

Exception thrown in a lock c#2

Hi, I've a strance behaviour with C#2, an exception is thrown will calling a lock(...). I have the following exception : System.Threading.ThreadAbortException: Thread was being aborted. at System.Threading.Monitor.Enter(Object obj)... Have you seen that kind of exception ? TIA ...

VB Equivalent of the following code for threads

What is the vb.net equivalent of the following c# code? var thread = new Thread(() => { Dispatcher.CurrentDispatcher.BeginInvoke ((Action)(() => new MySplashForm().Show())); Dispatcher.Run(); }); ...

Monitor Threads in Windows Service

I have a windows service that spawns off around 60 threads when it starts. I am using Nagios for general monitoring and I have all necessary routines to send data to nagios. However, I cannot figure out how to get a sum of all threads and make sure that none of them are dead. Basically what I want to do is: foreach(thread t in threadP...

Does a Deadlock Occur in This Case?

Am I right in saying that a deadlock is supposed to happen in the following case: Object P calls a synch method of object A, that calls a synch method of object B, that calls a synch method of object A. Sorry if it looks stupid of me, most probably it is. But that's why I'm asking. Thanks! ...

Socket message hangs until thread completes in Perl

I am trying to write Perl code that does two-way communication over a Unix socket. It needs to do the following things: Client code sends a request over the socket Server code reads the request Server performs any actions that should happen immediately Server creates a new thread to do additional actions that may take a long time Serv...

NSThread called second time (after first didn't finish) get "EXC_BAD_ACCESS"

Hello I have a cover flow and it has 3 different image sets. One of them needs to be generated and I have been trying to get it populated with a thread for larger selections of images. Here is a bit of my code: - (void) startSongThread { [NSThread detachNewThreadSelector:@selector(songThreadMain) toTarget:self withObject:nil]; ...