multithreading

Is NSPasteboard thread-safe?

Is it safe to write data to an NSPasteboard object from a background thread? I can't seem to find a definitive answer anywhere. I think the assumption is that the data will be written to the pasteboard before the drag begins. Background: I have an application that is fetching data from Evernote. When the application first loads, it g...

Interrupting a thread from inside a runnable class? (java)

I am trying to set up a method inside a class that implements the runnable interface that will set the interrupt status of that class. The reason i want to be able to do it from inside the class is there is some other clean up stuff that i need to take care of as well, and i would like to be able to do it all by calling one method instea...

DispatcherOperations.Wait()

What happens if you call dispatcherOperation.Wait() on an operation that has already completed? Also, the docs say that it returns a DispatcherOperationStatus, but wouldn't that always be Completed since it (supposedly) doesn't return until it's done? I was trying to use it like this: private void Update() { while (ops....

Is there any class in the .NET Framework to represent a holding container for objects?

I am looking for a class that defines a holding structure for an object. The value for this object could be set at a later time than when this container is created. It is useful to pass such a structure in lambdas or in callback functions etc. Say: class HoldObject<T> { public T Value { get; set; } public bool IsValueSet(); public v...

What the best multi-thread application debugger for C++ apps.

I'm looking for a good multi-thread-aware debugger, capable of showing performance charts of application threads on Linux, don't know if such a thing exists, perhaps as a Eclipse plugin. The idea would be to track per thread memory allocation a CPU usage as well as being able to interrupt a thread and examine its stack trace, local vars,...

Multithreaded Applications

Hi All I have been reading the articles on MSDN, but my mind is dead (this usually happens when I read MSDN (No offense MSDN, but your articles confuse me at times.)), and I'm trying to do some "background work" in my app, but not sure how. It's just a single method. But the application hangs, and I have to wait up to 1 - 3 minutes for ...

iPhone "multi-threading" question

I have a simple iPhone game consisting of two "threads": the main game loop where all updating and rendering happen 30 times per second (NSTimer)... and the "thread" that calls the accelerometer delegate 100 times per second. I have a variable "xPosition" that's updated in the accelerometer delegate function and used in the game loop. ...

A member variable's hashCode() value is different

There's a piece of code that looks like this. The problem is that during bootup, 2 initialization takes place. (1) Some method does a reflection on ForumRepository & performs a newInstance() purely to invoke #setCacheEngine. (2) Another method following that invokes #start(). I am noticing that the hashCode of the #cache member variable ...

Win32 Thread Exits Unexpectedly

Hello, I'm writing a C++ application. I realized that one of my worker threads may terminate unexpectedly. The (VS 2005) debug log says: The thread 'Win32 Thread' (0x5d98) has exited with code -858993460 (0xcccccccc). I surrounded all the worker thread code with a try/catch block. So, if the reason was an exception, I would cat...

Why the gtk windows hangs?

void forloop2() { int i = 0; while(TRUE) { printf("forloop2\n"); } } int main() { GtkWidget *window; g_thread_init(NULL); gdk_threads_init(); g_thread_create((GThreadFunc)forloop2, NULL, FALSE, NULL); gtk_init(NULL, NULL); window = gtk_window_new(GTK_WINDOW_TOPLEVEL); gtk_widget_show_a...

ContextSwitchDeadlock Was Detected error in C#

Hi, I am running a C# application, and during run-time I get the following error: The CLR has been unable to transition from COM context 0x20e480 to COM context 0x20e5f0 for 60 seconds. The thread that owns the destination context/apartment is most likely either doing a non pumping wait or processing a very long running operation withou...

How do I make child thread exit when main thread exit?

void forloop2() { int i = 0; while(TRUE) { printf("forloop2\n"); } } int main() { GThread *Thread1; GtkWidget *window; g_thread_init(NULL); gdk_threads_init(); gdk_threads_enter (); Thread1 = g_thread_create((GThreadFunc)forloop2, NULL, TRUE, NULL); gtk_init(NULL, NULL); w...

.NET: Start a thread as suspended

In unmanaged code you can create a thread in suspended state. In .NET Framework I can't find this option. Is it because the Thread constructor puts the thread in a suspended state? Is there other reason why this is not supported? ...

Is is necessary to create a Mutex for a read-only thread and a write-only thread?

There are 2 threads,one only reads the signal,the other only sets the signal. Is it necessary to create a mutex for signal and the reason? UPDATE All I care is whether it'll crash if two threads read/set the same time ...

Named semaphores in Python?

Hi, I have a script in python which uses a resource which can not be used by more than a certain amount of concurrent scripts running. Classically, this would be solved by a named semaphores but I can not find those in the documentation of the multiprocessing module or threading . Am I missing something or are named semaphores not imp...

.NET: Control Invoke() in Reflector

So, I was getting back into some .NET programming, and through a new feature in VS.NET 2010, it detected a case where I was trying to modify a control from a thread that didn't create that control, and pointed me to an article on MSDN about how you do this correctly... ' HOW TO WRITE TO A FORM CONTROL FROM A THREAD THAT DIDN'T CREATE TH...

Thread safety in C# arrays

Does having 2 different threads : one reading from a C# array (e.g from first location), and another one writing to the same C# array but to a different location(e.g to the last location) is thread safe or not? (And I mean here without locking reading nor writing) ...

Update UI in the main activity through handler in a thread (Android)

Hello, I try to make several connection in a class and update the multiple progressbar in the main screen. But I've got the following error trying to use thread in android : Code: 05-06 13:13:11.092: ERROR/ConnectionManager(22854): ERROR:Can't create handler inside thread that has not called Looper.prepare() Here is a small part ...

"Multi-threading" w/ NSTimers in an iPhone app

Say I have two NSTimers in my iPhone app: timer1 and timer2. timer1 calls function1 30 times per second and timer2 calls function2 30 times per second. Assume these two functions are reading and updating the same integer variables. Are there any "multi-threading" issues here? If not how does iPhone OS handle the execution of the two...

Putting a thread to sleep until event X occurs

I'm writing to many files in a threaded app and I'm creating one handler per file. I have HandlerFactory class that manages the distribution of these handlers. What I'd like to do is that thread A requests and gets foo.txt's file handle from the HandlerFactory class thread B requests foo.txt's file handler handler class recognizes tha...