multithreading

how to declare a function which is member of a class and returns a function pointer to a thread?

Hi All, I want to write a function(say foo) which takes string as an argument and returns a function pointer ,however this pointer points to following function: DWORD WINAPI fThread1(LPVOID lparam) Also the function(foo) is member of a class so i will be defining it and declaring it in seperate files(header and .cpp files). Please h...

How to get how many threads are running in multithreaded windows service application.

I have a multithreaded windows service application, I want to know every moment how many threads(with thread id, thread name, corresponding process id) are running which are created by my application. Thank in advance. ...

ThreadPool Tasks That Depends on the Completion of Other Tasks

In our current project, for some operations we send messages to Database like COMPLETED-Order,STARTED-Request, REJECTED-Order with related information like OrderId.... All the messages correspond a Command class that implements Command Pattern. interface ICommand { void Execute(); } public class RequestStartedCommand:ICommand { p...

Threads in python

I am beginar in python script. I want read msaccess database records and write into XML file. Access database table have more than 20000 records. Now i am able to do but , it is taking 4 to 5 minutes. So i implement threading concept. But threading also taking more than 5 to 6 minutes. Because each thread open datasource reading records...

[Ruby] Threads or DRb?

I need to have 2 (or maybe 3) continuously running "facets" of a program in Ruby - a communications thread, a render thread and maybe a caching thread. The idea is the rendering thread shows a slide-show (whose definition is read from file) and all slides are retrieved from a remote HTTP server by the communications thread. The renderi...

how to prioritize user define messages in a thread?

I have an only one thread (Windows app) which receives windows and user-defined messages. Right now, when user clicks the mouse and keep pressed the application locks. How can I resolve this? I have the restriction of one thread. ...

return two values out of a remote thread (C, windows)

I currently have a thread that I created using CreateRemoteThread(). Everything works great. Upon finishing (or an error before completion) the thread returns one of the five return codes that we defined. I run into a problem and I need to return the results of GetLastError() as well. Is there any way to return two values? I am using W...

Notify parent thread when child has performed a certain action [C#]

I have a parent thread (non-UI) which creates some child threads to do some jobs - at some point the parent must wait for certain tasks to be completed by the child thread - this does not mean the child is finished but only that it has reached a certain point and the parent can now continue processing ... To illustrate please refer to t...

How do I create a file in python without overwriting an existing file

Currently I have a loop that tries to find an unused filename by adding suffixes to a filename string. Once it fails to find a file, it uses the name that failed to open a new file wit that name. Problem is this code is used in a website and there could be multiple attempts to do the same thing at the same time, so a race condition exi...

Problems starting a thread in a Word 2007 Ribbon Add-in

I created a Word 2007 add-in project in C# that works fine on my box and a fellow developer's box. When we try to deploy the software to a blank box though, Word crashes hard (no exception thrown) when we start up a background thread. Here's the relevant code, in the Ribbon.cs file: private void startThread() { StreamWriter fout =...

Debugging and diagnosing lock convoying problems in .NET

I am looking into performance issues of a large C#/.NET 3.5 system that exhibits performance degradation as the number of users making requests scales up to 40-50 distinct user requests per second. The request durations increase significantly, while CPU and I/O loads appear to stay about the same. This leads me to believe we may have pr...

My Timer event crashes because the events are called on a different thread.

I get the error "Cross-thread operation not valid: Control 'label1' accessed from a thread other than the thread it was created on." when I run this code: using System; using System.ComponentModel; using System.Data; using System.Text; using System.Windows.Forms; using System.Timers; namespace WindowsFormsApplication1 { public part...

lock free arena allocator implementation - correct?

for a simple pointer-increment allocator (do they have an official name?) I am looking for a lock-free algorithm. It seems trivial, but I'd like to get soem feedback whether my implementaiton is correct. not threadsafe implementation: byte * head; // current head of remaining buffer byte * end; // end of remaining buffer void * All...

seg faults due to multithreading (using boost libraries)

We have a program that uses both boost's matrix and and sparse matrix libraries and we are attempting to integrate boost threads. However, when we move from a single-threaded to multi-threaded application we are getting segmentation faults that do not occur in the single-thread case. We've debugged using gdb (in Eclipse) and I've found...

Thread priority has no effect?

I created a simple .NET console application and within it I start 3 managed threads. Each thread executes the following loop: while (true) { System.Console.WriteLine(thread.Name + " " + DateTime.Now); Thread.Sleep(10); } I set the first thread's priority to high and let the app run for ...

Is it safe to read an integer variable that's being concurrently modified without locking?

Suppose that I have an integer variable in a class, and this variable may be concurrently modified by other threads. Writes are protected by a mutex. Do I need to protect reads too? I've heard that there are some hardware architectures on which, if one thread modifies a variable, and another thread reads it, then the read result will be ...

How can you test if a thread is the only remaining thread in Java?

I want a thread in a Java program to loop until all other threads die, and then end the loop. How can I know when my loop thread is the only thread remaining? In my situation, the loop thread will have no reference to any other threads, so I don't think isAlive() helps me. ...

QThread::wait() and QThread::finished()

Does QThread::wait() return (i.e., unblocks execution) after calling all the slots that were associated with QThread::finished() signal? Thanks in advance. ...

UI update with multiple concurrent operations.

I am developing an application in C# using National Instruments Daqmx for performing measurements on certain hardware. My setup consists of several detectors from which I have to get data during a set period of time, all the while updating my UI with this data. public class APD : IDevice { // Some members and properties go here, ...

How to kill a Thread with Objective C?

Hi there, I have a call to a third-party C++ library which I have put into its own thread (currently using NSThread). I would like to give the user the ability to stop the execution of that thread. (I am well aware of all the problems this might cause, but I still wish to do so.) According to Apple's Thread Programming Guide, there ar...