multithreading

question about STL thread-safe and STL debugging

I have two questions about STL 1) why STL is not thread-safe? Is there any structure that is thread-safe? 2) How to debug STL using GDB? In GDB, how can I print a vector? ...

My Thread Programs Crash

I have a problem with threads objectiveC. The line of code below contains the recv block the program waiting for a datum. My intention is to launch a thread parallel to the program so that this statement does not block any application. I put this code in my program but when active switch the program crashes. Enter the code. -(IBAction)C...

Threading best practice when using SFTP in C#

Ok, this is more one of these "conceptual questions", but I hope I got some pointers in the right direction. First the desired scenario: I want to query an SFTP server for directory and file lists I want to upload or download files simulaneously Both things are pretty easy using a SFTP class provided by Tamir.SharpSsh, but if I only...

Does this use of Monitor.Wait/Pulse have a race condition?

I have a simple producer/consumer scenario, where there is only ever a single item being produced/consumed. Also, the producer waits for the worker thread to finish before continuing. I realize that kind of obviates the whole point of multithreading, but please just assume it really needs to be this way (: This code doesn't compile, but...

Java: Handling exceptions in child threads....

I prefer to have the exception handling logic further up in the call stack, near the main method. I like this approach... However, I created a thread where some of its method calls inside run() may throw exceptions. I would really like to see if there is a way that these exceptions can be thrown back up to the parent thread? The best I c...

How to create a run loop that only listens to performSelector:onThread: and GUI events?

I want to create a separate thread that runs its own window. Frankly, the documentation does not make sense to me. So I create an NSThread with a main function. I start the thread, create an NSAutoreleasePool, and run the run loop: // Global: BOOL shouldKeepRunning = YES; - (void)threadMain { NSAutoreleasePool *pool = [NSAutorelea...

Show form that showDialog from mainForm won't block it, but closing mainForm will close it

how yo show a form which needs to run synchronously. I tried running application.run from a queueworker of a threadpool- but I had some invalid handles sometime. tried using a regular thread but then when main form closes it doesn't close this- and I don't really like the idea of killing the thread on_formclosing. if I use form.show it's...

Application threads vs Service threads

What are the advantages/disadvantages in placing a lengthy network access code in a thread in an activity or a thread in a service? How would it affect the application? I am writing a streaming audio player and from what I've read so far putting the code in a service will still end up blocking the application so a new thread is needed,...

Is there any way to name external threads?

TThread.NameThreadForDebugging is great for telling threads apart, but not all of my threads are TThread descendants. I have some that are created by an external library that's not even written in Delphi. Is there any way to name them if I can find a way to get their thread handles? ...

@synchronized doesn't work in static library

For some reason, when I try to use @synchronized in a static library for the iPhone, I get an error in the project that uses it: Undefined symbols: "___restore_vfp_d8_d15_regs", referenced from: -[GVInbox addConversation:] in libGVKit.a(GVInbox.o) "___save_vfp_d8_d15_regs", referenced from: -[GVInbox addConversation:] in...

How can I limit access to a particular class to one caller at a time in an ASMX web service?

I have a web service method in which I create a particular type of object, use it for a few seconds, and then dispose it. Because of problems arising from multiple threads creating and using instances of this class at the same time, I need to restrict the method so that only one caller at a time ever has one of these objects. To do thi...

Symbian qt threading

Hi, 1) In symbian c++ thread is not recommended. Instead of that they recommend active object for multi tasking. Presently I am using QT to develop a application in symbian. Since there is no active object in QT I thought of using thread. My question is , can I use thread, is it is recommended. If it is not recommended, how to achie...

Microsoft Detours - DetourUpdateThread?

Hi, I have a few quick questions about the Microsoft Detours Library. I have used it before (successfully), but I just had a thought about this function: LONG DetourUpdateThread(HANDLE hThread); I read elsewhere that this function will actually suspend the thread until the transaction completes. This seems odd since most sample code c...

Parallel version of loop not faster than serial version

I'm writing a program in C++ to perform a simulation of particular system. For each timestep, the biggest part of the execution is taking up by a single loop. Fortunately this is embarassingly parallel, so I decided to use Boost Threads to parallelize it (I'm running on a 2 core machine). I would expect at speedup close to 2 times the...

In C# how to show a GUI from another GUI, based on the event from a class in another thread?

I am working on a DirectX based simulator. On which I have to check for a device whether device has been plugged-in or removed from the PC. I've managed to make classes for device arrival and removal on another thread, which raises an event from the thread itself on device arrival or removal. The corresponding event method is being call...

I just can't kill Java thread.

I have a thread that downloads some images from internet using different proxies. Sometimes it hangs, and can't be killed by any means. public HttpURLConnection uc; public InputStream in; Proxy proxy = new Proxy(Proxy.Type.HTTP, new InetSocketAddress("server", 8080)); URL url = new URL("http://images.com/image.jpg"); uc = (HttpURLConne...

controlling threads flow

I had a task to write simple game simulating two players picking up 1-3 matches one after another until the pile is gone. I managed to do it for computer choosing random value of matches but now I'd like to go further and allow humans to play the game. Here's what I already have : http://paste.pocoo.org/show/201761/ Class Player is a co...

Can two or more threads iterate over the same List<t> without any problems?

Talking about System.Collections.Generic.List<T> here. With example below can Method1 and Method2 execute and the same time, on different threads without any problems? Thanks class Test { private readonly List<MyData> _data; public Test() { _data = LoadData(); } private List<MyData> LoadData() { ...

Does SetThreadPriority cause thread reschedulling?

Consider following situation, assuming single CPU system: thread A is running with a priority THREAD_PRIORITY_NORMAL, signals event E thread B with a priority THREAD_PRIORITY_LOWEST is waiting for an event E (Note: at this point the thread is not scheduled because it is runnable, but A is higher priority and runnable as well) thread A ...

QTJambi - QNetworkManager from thread doesn't emit signals

I am new to QT(jambi). I have a very simple QTJambi (4.5.2) app. I am trying to figure out why this will not work (DoResponseReady never called) within a thread. Switch the static variable between threaded=true/false to reproduce. import com.trolltech.qt.core.QByteArray; import com.trolltech.qt.core.QUrl; import com.trolltech.qt.gui.QA...