multithreading

How to manage object life time using Boost library smart pointers?

Hi, There is a scenario that i need to solve with shared_ptr and weak_ptr smart pointers. Two threads, thread 1 & 2, are using a shared object called A. Each of the threads have a reference to that object. thread 1 decides to delete object A but at the same time thread 2 might be using it. If i used shared_ptr to hold object A's refere...

Java: What is the rough "Cost" of a Thread (CPU Cycles / Memory) ?

Hello, I would be greatfull for help regarding my question. What is the rough "cost" of using threads in java? Are the any rule of thumbs/empirical values, how much memory the creation of one thread costs. (This is my main question). Furthermore is there a rough estimate how many "cpu cycles" the creation of a thread costs? The motiva...

What happens if I ReleaseMutex() twice?

The Microsoft documentation is silent about what happens if I mistakenly call ReleaseMutex() when the mutex is already unlocked. Details: I'm trying to fix up some Windows code without having access to the compiler. I realise that WinApi mutexes are all recursive, and reference-counted. If I were making use of that feature, it's obvi...

Threaded drawing onto a canvas in Java SWT

I've been working quite a bit on something I can only describe as a "threaded canvas" for some time now. In a moment I'll describe what I have, but since I'm really open to new ideas, existing solutions or a completely fresh start, I'll formulate the problem. The canvas is intended to display genetic information (although the specific p...

Best method for saving values of a queue in case of program failure

Say I have a multithreaded application made up of two separate threads and a Queue. Thread 1 finishes it's computation and puts the result in the Queue. Meanwhile thread 2 is constantly looping and checking if there is any data in the Queue for it to process. How can I save the values in the queue to disk temporarily in case the for so...

What's the best way to discover why threads are being created in my C++ app and what they do?

I am doing an audit of a C++ app running on Windows, compiled against multithreaded debug DLL. It has a lot of third party dependencies which can spawn threads. I need to track why each thread is there and how much stack space it is allocating. What is a good way to trace back to the start of a thread's creation so I can see where it ...

Request for code review: does such XmlSerializer factory have any drawbacks?

Hi! People tend to recommend to cache XmlSerializer instances. Is this still actual? (if no, when has it become so?). Also I came up with the following code and ask to review it. Does it have any drawbacks? Will it use many threads\cores for different types? How can I improve it? The code: public static class SerializerFactory<T> ...

RichTextBox Control in a Multi-Threaded Application

I'm using a RichTextBox control in a Windows Service to convert RTF to plain text. This method is actually mentioned by MS here: http://msdn.microsoft.com/en-us/library/cc488002.aspx My Windows Service spawns multiple threads (typically 2 x the number of CPU cores), and each of these threads ends up instantiating a separate instance of ...

Session variables in JSP

How is a session object attached to each thread of a servlet? I believe its not a ThreadLocal, so how is it attached to each servlet thread? ...

wxpython -- threads and window events

I have a wxPython application (http://www.OpenSTV.org) that counts ballots using methods that have multiple rounds. I'd like to do two things: (1) For a large number of ballots, this can be a bit slow, so I'd like to show the user a progress dialog so he doesn't think the application is frozen. (2) I'd like to allow the user to break ...

Send a message to a Windows Forms message loop

I have a thread that reads messages from a named pipe. It is a blocking read, which is why it's in its own thread. When this thread reads a message, I want it to notify the Windows Forms message loop running in the main thread that a message is ready. How can I do that? In win32 I would do a PostMessage, but that function does not seem t...

Embedded Ruby 1.9.1, signals and multithreading

I am embedding ruby (1.9.1) as a scripting language in my window manager project (subtle). Since the switch from 1.8 to 1.9 I am facing many problems with asynchronous signals in multithreading. How is signal handling supposed to work and does the thread that ruby creates automatically have any own signal handlers? Due the asynchronous ...

Windows Service that runs Periodically

I'm writing a windows service that once started will run every X hours. The process it completes is fairly intensive, so I want to use a background worker. I'm using a Settings file to store both the hours between runs and the last time the service ran. I'm not exactly sure the best way to do this - that is, I want the service to idle...

How to Tell if a Thread Pool is Idle in Java

I have a thread pool created using java.util.concurrent.ThreadPoolExecutor Is there anyway I can wait till the pool is idle? By which I mean all the threads are not running and nothing is waiting in the queue. I searched the web and all the solutions don't work for me. For example, I don't want shutdown the pool so awaitTerminatio...

named EventWaitHandle release order

When AutoResetEvent calls WaitOne on Process 1 and it is called again in Process2, and Process 2 calls Set on the same AutoResetEvent, shouldn't it release the lock on Process1 as it was called before the one in Process 2? I have a sample code which I used to execute Process 1 and 2. I run Process 1 without any arguments, so it hangs at...

Boost equivalent of ManualResetEvent?

Hello, I'm wondering if there is a boost equivalent of ManualResetEvent? Basically, I'd like a cross-platform implementation... Or, could someone help me mimic ManualResetEvent's functionality using Boost::thread? Thanks guys ...

how do you create a multi-threaded asp.net ajax update panel?

how do you create a multi-threaded asp.net ajax update panel? thanks! ...

iPhone dev multi threaded, NSAutoreleasePool

I have a simple application that counts down to midnight and then plays a beeping sound over and over again and blinks the label showing the time. So the label blinking uses an NSTimer, while the beeping goes on its own Thread, so that the pure C function (for the system sound id completion callback) can use [NSThread sleepForTimeInterva...

Does parallel work in an ASP.NET work process block connection threads?

Hi folks, i'm not sure I've used the correct terms in the title but this is my question. If i have a stock standard ASP.NET webpage (webforms or mvc) and i wish to do some longish processing, I create a new process and fire that off. Eg. save an uploaded file to a local folder then do some image manipulation on it Eg. save an uploade...

_beginthread in XPCOM Component error C2440

I want to start thread in XPCOM Component. Here is a code for creating thread nsresult rv = NS_OK; nsCOMPtr<Callback> obj = do_CreateInstance("@jscallback.p2psearch.com/f2f;1", &rv); NS_ENSURE_SUCCESS(rv, rv); char* str="Hello from C++"; _beginthread( (void(*)(nsCOMPtr<Callback> ))&P2P::test, 0,obj); return NS_OK;/...