multithreading

Clarification on Threads and Run Loops In Cocoa

I'm trying to learn about threading and I'm thoroughly confused. I'm sure all the answers are there in the apple docs but I just found it really hard to breakdown and digest. Maybe somebody could clear a thing or 2 up for me. 1)performSelectorOnMainThread Does the above simply register an event in the main run loop or is it somehow a n...

backgroundworkers or threadpools

I am trying to create an app that allows multiple search requests to occur whilst maintaining use of the user interface to allow interaction. For the multiple search requests, I initially only had one search request running with user interaction still capable by using a backgroundworker to do this. Now I need to extend these functions b...

JUnit, test and threads

Hi, when i run multiple JUnit tests in a row, does JUnit create a new thread for each execution or everything is wrapped in a single thread? Thanks ...

Async F# vs. CCR framework

After reading about CCR : http://www.infoq.com/news/2008/12/CCR I get the impression that it does pretty much exactly the same as F# async blocks? You yield port.Receive and port.Test in order to do the same as "let!". Is this correct? And are there any benefits in CCR that you don't get with F# async? ...

Passing data structures to different threads

I have an application that will be spawning multiple threads. However, I feel there might be an issue with threads accessing data that they shouldn't be. I'm relatively new to threading so bare with me. Here is the structure of the threaded application (sorry for the crudeness): MainThread / ...

Java: How to make this main thread wait for the new thread to terminate

I have a java class that creates a process, called child, using ProcessBuilder. The child process generates a lot of output that I am draining on a separate thread to keep the main thread from getting blocked. However, a little later on I need to wait for the output thread to complete/terminate before going on, and I'm not sure how to ...

C++0x thread interruption

According to the C++0x final draft, there's no way to request a thread to terminate. That said, if required we need to implement a do-it-yourself solution. On the other hand boost::thread provides a mechanism to interrupt a thread in a safe manner. In your opinion, what's the best solution? Designing your own cooperative 'interruption...

How to get a stable, snappy UI using threads?

I recently watching this video on Google Chrome with great interest. It explains that Google Chrome uses one thread for IO, one for opening files and one for intermodule communication. I think I may be able to use something similar for my own - currently quite messy - application. I wondered if there were any good articles on best-prac...

Maximizing the number of threads to fully utilize all available resources without hindering overall performance

Let's say I have to generate a bunch of result files, and I want to make it as fast as possible. Each result file is generated independently of any other result file; in fact, one could say that each result file is agnostic to every other result file. The resources used to generate each result file is also unique to each. How can I dynam...

Sockets: I/O Error 32

Could someone please explain what an I/O Error 32 refers to in the context of a network socket? I have a multithreaded Socks5 server written using Poco SocketReactors and am getting this error when the server load reaches a certain point. The exception is thrown within my onReadable handlers at the same time across all threads which hav...

Invoke a cleanup method for java user thread, when JVM stops the thread

Hi All I have J2SE application running in linux. I have stop application script in which i am doing kill of the J2SE pid. This J2SE application has 6 infinitely running user threads,which will be polling for some specific records in backend DB. When this java pid is killed, I need to perform some cleanup operations for each of the long...

Android: Quitting the Looper?

I have a thread I use to periodically update the data in my Activity. I create the thread and start a looper for using a handler with postDelay(). In onDestroy() for my activity, I call removeCallbacks() on my handler. Should I then call handler.getLooper().quit()? Or not worry about it and let the OS deal with it? Or would it just run ...

How do I create a new thread to make pcap_loop() and gtk_main() compatible?

These two functions are both infinite loops, and the programe hangs once called in the same thread. gtk_main(); ... pcap_loop(adhandle, 0, packet_handler, NULL); When I click the "start" button,I want pcap to start working;And if I press the "stop" button,pcap stop. How do I create a child thread and run pcap_loop(adhandle, 0, pack...

Sleep a thread until an event is attended in another thread from a different class

I have an application that fires 2 threads, the 1st launches another class to do some processing which in turn launches a 3rd class to do yet more processing. The 2nd thread in the main class should wait until some event in the 3rd class completes before it performs its job. How can this be achieved? I had tried implementing a wait/not...

All Callbacks on GUI Thread - Multithreading issues possible?

We have an external data provider which, in its construtor, takes a callback thread for returning data upon. There are some issues in the system which I am suspicious are related to threading, however, in theory they cannot be, due to the fact that the callbacks should all be returned on the same thread. My question is, does code lik...

IS ResultSet thread safe

Is ResultSet Thread safe? My question arises because in my program i have used different statement for each query i have declared a ResultSet as an local variable but it gives me a error of Operation not allowed after ResultSet is closed. But my statements are working as i'm using the statements in insert and delete query.I have commen...

Shutting down a windows service that has threads

I have a windows service written in .NET 3.5 (c#) with a System.Threading.Timer that spawns several Threads in each callback. These are just normal threads (no Thread Pool) and I've set the IsBackground = true on each thread since I'm only going to be running managed code. When a user stops the service, what happens to all the threads? ...

[java] Threading socket handler for two sided communication in tcp port

I want to make a chat which will be programed in java. one computer will host the server and the other one will initiate the socket [tcp port]. now from what I read there should be a loop that will constantly read the socket which means it will make the code stuck. I have a button that is 'actionperformed' on mouse release, I want to kno...

Is there no way to iterate over or copy all the values of a Java ThreadLocal?

Context: static ThreadLocal<MyType> threadLocalMyType = ... What i'd like is to say something like: for (ThreadLocalEntry e: threadLocalMyType.getMapLikeThing() { // Thread t = e.getKey(); // I don't need the thread value right now, but it might be useful for // something else. MyType theMyType = e.getValue(); ...

problem with implementing a simple work queue

Hi all, I am having troubles with implementing a simple work queue. Doing some analysis, I am facing a subtle problem. The work queue is backed by a regular linked list. The code looks like this (simplified): 0. while (true) 1. while (enabled == true) 2. acquire lock on the list and get the next action to be executed (b...