multithreading

python threading question

okay, I'm learning how to pool threads in python. I'm relatively new to threading in general and I have a question. In the following code, you see that the pickledList variable thats being used by the thread is set in the global scope. This is an example from a howto on a website. My question is: what if the variable that the thread was ...

Opening a wx.Frame in Python via a new thread

I have a frame that exists as a start up screen for the user to make a selection before the main program starts. After the user makes a selection I need the screen to stay up as a sort of splash screen until the main program finishes loading in back. I've done this by creating an application and starting a thread: class App(wx.App): ...

Winform GUI Thread - Should there be a single catch block ?

I have read it here : CodeProject and some other places that there should be a single catch block per thread. I don't quite understand this in context of winforms. Is it true also in case of winforms? I understand that worker threads should have a single catch block. But, I have multiple catch blocks on the UI(main) thread which always ...

is there a way to pause an NSTHread indefinitely and have it resumed from another thread?

Seems these are the only methods to put a NSThread to sleep * sleepForTimeInterval: * sleepUntilDate: Would it be bad practice what I am asking? ...

Accessing main thread from a Timers.Timer in .NET

Hi there, I have a Timer that monitors certain conditions (like if a Process is running) and when those conditions are met I must create a hook (SetWinEventHook). The problem is that the hook must be created on the main thread, otherwise my callback doesn't return. How to do that? I've tried everything, and the only way that this worked...

Message passing to asynchronus working thread in Java J2ME

I'm working on a J2ME Bluetooth application, and one of the classes searches for other Bluetooth devices. It does this in another thread, so the GUI doesn't freeze up. The problem I have is how to pass messages to the thread. I can ask it to search, or cancel searching, and it can tell the GUI it has found some other devices. Currently...

.net async socket timeout check thread-safety

http://msdn.microsoft.com/en-us/library/system.net.sockets.socketasynceventargs.aspx Starting with the above msdn example I'm trying to write a timeout check which will close inactive client sockets and free up resources. This is what I have come up with. But I'm not sure if its completely thread-safe and if there is a better way to do...

Lock Free Array Element Swapping

In multi-thread environment, in order to have thread safe array element swapping, we will perform synchronized locking. // a is char array. synchronized(a) { char tmp = a[1]; a[1] = a[0]; a[0] = tmp; } Is it possible that we can make use of the following API in the above situation, so that we can have a lock free array ele...

WPF ICollectionView Refresh

Hi. Is there any way how to do ICollectionView.Refresh() or CollectionViewSource.GetDefaultView(args.NewValue).Refresh(); in a separate thread? I know I can use dispatcher, but this collection is binded to a ListView and it throws cross thread Exceptions. The reason why I need a second thread is, that I have Control which dis...

Are threads really not being garbage collected on WTK emulator?

I'm pretty sure I'm not going mad when I say that Thread objects do not seem to be garbage collected in my J2ME application when running on the WTK emulator (v 2.5.2_01). I have a console message when my run method exits, and it is printed. At the same time I make a call back to the only object that has a reference to the thread and tel...

Clean Invoke patterns?

Right now, I have a windows application (C#) that spits out long running reports. Each report grabs some information from the UI to constrain the reports. Of course, the report creation happens on a background thread and I need to properly invoke the various controls to get things like selected indexes and values. But I don't think my ...

Trouble with NativeWindow constructed in a thread context

I'm creating a NativeWindow subclass ('MyNativeWindow') in order to use its message pump to communicate with some old DLL. My code runs inside a WinForms application, but I'd like to keep the DLL and it's message processing outside the scope of the GUI. When creating MyNativeWindow from the application context (just before creating my a...

what are the usages of atomic ways?

how atomic ways can make our codes thread-safe? ...

Best ways to handle maximum execution time for threads (in Java)

So, I'm curious. How do you handle setting maximum execution time for threads? When running in a thread pool? I have several techniques but, I'm never quite satisfied with them. So, I figure I'd ask the community how they go about it. ...

Java 5: java.util.concurrent.FutureTask - Semantics of cancel() and done()

I am currently hunting a nasty bug in a multi-threaded environment using FutureTasks and Executors. The basic idea is this to have a fixed number of threads execute individual FutureTasks that compute a result that is to be displayed in a a table (never mind the GUI aspect here). I have been looking at this for so long, I am beginning ...

C++ Socket Server - Unable to saturate CPU

I've developed a mini HTTP server in C++, using boost::asio, and now I'm load testing it with multiple clients and I've been unable to get close to saturating the CPU. I'm running on a 4-cpu box, and getting about 50% usage of one cpu, 20% of another, and the remaining two are idle (according to htop). Details: The server fires up on...

Can producer-consumer problem be solved without using assignment?

I am interested in finding if producer-consumer problem when there are multiple produce and multiple consumer be solved without using assignment i.e., using functional style of programming? How? Producer-consumer problem Thanks ...

C++ multiple processes?

I've got a project that consists of two processes and I need to pass some data between them in a fast and efficent manner. I'm aware that I could use sockets to do this using TCP, even though both processes will always exist on the same computer, however this does not seem to be a very efficient solution. I see lots of information abou...

ReaderWriterLockSlim implements single writer, or requires single writer?

I think I am having a brain fart. This sould be a very simple question: does ReaderWriterLockSlim IMPLEMENT the single writer concept, or does it REQUIRE a single writer thread? ...

fork in multi-threaded program

I've heard that mixing forking and threading in a program could be very problematic, often resulting with mysterious behavior, especially when dealing with shared resources, such as locks, pipes, file descriptors. But I never fully understand what exactly the dangers are and when those could happen. It would be great if someone with expe...