multithreading

Is this use of PreparedStatements in a Thread in Java correct?

I'm still an undergrad just working part time and so I'm always trying to be aware of better ways to do things. Recently I had to write a program for work where the main thread of the program would spawn "task" threads (for each db "task" record) which would perform some operations and then update the record to say that it has finished. ...

Start and run a class member function in background, in QT/C++

Once a minute I want to run a task, not blocking other GUI functions. I heared somthing about QConcurent::run ... Or should I use signals and slots? ...

LWUIT Deadlock (lwuit dialog VS System dialog)

Hi, I have a deadlock problem when I try to make some I/O operations that needs user permission. When user click the button I start a new thread which is responsible for performing IO operations, and I display lwuit "please wait" dialog. Dialog is dismissed by IO thread from callback method. Problem is that, when system dialog appears (...

Multiple open file for reading at same time

I want to use dup2 to read from input file and redirect it to the input of exec function. but my problem is i have three running process all of them have to open same input file but they do different jobs. what your suggest in such case? i don't know if it is possible to use "cat data.txt" to feed the input for the three other process bu...

Lockless queue implementation ends up having a loop under stress

I have lockless queues written in C in form of a linked list that contains requests from several threads posted to and handled in a single thread. After a few hours of stress I end up having the last request's next pointer pointing to itself, which creates an endless loop and locks up the handling thread. The application runs (and fails...

Where Does A UIAlertView Live While Not Dismissed

Does anyone know in whose subview an active UIAlertView is located or how to find the thread in which it is running? ...

[Cocoa] Placing an NSTimer in a separate thread

Note: It's probably worth scrolling down to read my edit. I'm trying to setup an NSTimer in a separate thread so that it continues to fire when users interact with the UI of my application. This seems to work, but Leaks reports a number of issues - and I believe I've narrowed it down to my timer code. Currently what's happening is that...

How to synchronize access to many objects

I have a thread pool with some threads (e.g. as many as number of cores) that work on many objects, say thousands of objects. Normally I would give each object a mutex to protect access to its internals, lock it when I'm doing work, then release it. When two threads would try to access the same object, one of the threads has to wait. No...

UI thread is blocking a background thread calling a COM object

Hello, I am working on an application that communicates with an external device via a third-party COM library. I'm attempting to have all communication to the device go through a background thread both to prevent problems with communication from screwing up my app and to get rid of some other complexities introduced by having communica...

c++ multithread

I use C++ to implement a thread class. My code shows in the following. I have a problem about how to access thread data. In the class Thread, I create a thread use pthread_create() function. then it calls EntryPoint() function to start thread created. In the Run function, I want to access the mask variable, it always shows segment fault...

Lightweight spinlocks built from GCC atomic operations?

I'd like to minimize synchronization and write lock-free code when possible in a project of mine. When absolutely necessary I'd love to substitute light-weight spinlocks built from atomic operations for pthread and win32 mutex locks. My understanding is that these are system calls underneath and could cause a context switch (which may be...

c++ multithread

I use c++ to implement a thread class. The code is in the following. I initialize two objects, wish it will start two threads (I use pthread_self() to look the thread Id). But the result shows that there is only one thread beside the main thread. I am a bit confused... class Thread { public: int mask; pthread_t thread; Thread( in...

WPF Background Thread Invocation

Maybe I'm mis-remembering how Winforms works or I'm overcomplicating the hell out of this, but here's my problem. I have a WPF client app application that talks to a server over WCF. The current user may "log out" of the WPF client, which closes all open screens, leaves only the navigation pane, and minimizes the program window. When th...

How to maintain a pool of names ?

I need to maintain a list of userids (proxy accounts) which will be dished out to multithreaded clients. Basically the clients will use the userids to perform actions; but for this question, it is not important what these actions are. When a client gets hold of a userid, it is not available to other clients until the action is completed....

ThreadPool.QueueUserWorkItem new Form CreateHandle Deadlock

I have a thread that needs to create a popup Window. I start the thread using ThreadPool.QueueUserWorkItem(new WaitCallback(CreatePopupinThread)) Thew thread creats a new form. The application freases in the new Form constructor at CreateHandle. The Worker Thread is locked... How can I fix this? this is how I create the form var form ...

gracefully stopping a windows service with mutlithreaded processing on a timer thread?

Hi, Any ideas on gracefully stopping a windows service with mutli-threaded processing on a timer thread? Is it possible to add some infinite loop logic in the OnStop method to postpone the service shutting down. ...

WaitForSingleObject and WaitForMultipleObjects equivalent in linux

Hi, I am migrating an applciation from windows to linux. I am facing problem w.r.t WaitForSingleObject and WaitForMultipleObjects interfaces In my application I spawn multiple threads where all threads wait for events from parent process or periodically run for every t seconds. How can I implement this in Unix. I have checked pthread...

Can I find out which thread is running using Eclipse?

I close my application by pressing a "Close" button. But in the Eclipse I see a red square indicating that something is still running. When I press this red square, I kill my application completely. Is it possible to find out what is still running (which method, which loop) using Eclipse? P.S. I am a newbie. So, it would be nice to ha...

BufferedReader in a multi-threaded environment

How to read from BufferedReader simultaneously by multiple threads. ...

groovy thread for urls

I wrote logic for testing urls using threads. This works good for less number of urls and failing with more than 400 urls to check . class URL extends Thread{ def valid def url URL( url ) { this.url = url } void run() { try { def connection = url.toURL().openConnection() connection.setConnectTimeout(10000)...