multithreading

Poll is causing crash

Hi, I am getting a crash with following values :- Poll is the system call in use giving "errno" as 24 (EMFILE) and struct pollfd has values "fd = 1022, events = 1, revents = 32" Here we are woking on "fd = 1022" then why it is showing "errno" as 24 (EMFILE /Too many files open/) I have multiple threads which works in an Infinite loop...

Thread at language level

I'm reading about threads and in many books is said that Java support threads at language level and at a high-level trough the java.util.concurrent package. What does it meaning supporting thread at language level? I think Erlang is a language that support thread at language level... ...

Is it possible to enforce shared-nothing multithreading at the level of the OS or programming language? (OSX, Objective-C)

I'm trying to implement an actor model of concurrency in Objective-C, because I want to avoid the infamous problems of shared mutable state, locks, semaphores, etc. It can be done, but it takes real discipline to avoid accidentally using shared state. One way to enforce the shared-nothing rule is to use separate processes instead of se...

safely Access Dictionary in another thread?

I have a 2nd thread where i run a never ending loop (it listens to incoming TCP request). In that thread/loop i update a dictionary with holds my core data. In my winform GUI i would like to access the dictionary and display info. However if i write a foreach loop i get the exception that the dictionary has been modified. How do i safe...

java executor with pre-emptable thread queue.

I'm looking for a java thread-pool, that won't run more threads simultaneously than there are cores in the system. This service is normally provided by a ThreadPoolExecutor using a BlockingQueue. However, if a new thread is scheduled to execute, I want the new thread to pre-empt one of the already running threads, and add the the pre-em...

IceFaces accumulate view problem

I am uploading a file in IceFaces application through thread. After file upload is done, I am showing javascript message. Message is shown after some action or event is fired from view page. I want to show them soon after uploading gets completed, in console it prints the successful message properly. Following warning message is shown...

Update a TextBlock with elapsed time causing an UnauthorizedAccessException

I have a very simple StopWatch application in Silverlight. I have the following private properties in my MainPage class: _StopPressed (bool), _TimeStart, _Elapsed (string). I also have a "Start" and "Stop" button. The "Start" button calls a method called UpdateTime that constantly updates _ElapsedTime until _StopPressed is true. Wh...

Proper use of mutexes in Python

Hello all. I am starting with multi-threads in python(or at least it is possible that my script creates multiple threads). would this algorithm be the right usage of a Mutex? I haven't tested this code yet and it probably won't even work. I just want processData to run in a tread(one at time) and the main while loop to keep running, even...

OpenGLES fails to generate Framebuffers in iPhone thread

Hello, I've got a lovely OpenGLES code slice that renders up images for me. When I want to, I can call a function on it: -(UIImage *)renderToImage; That does a lot of rendering work and returns me an image. This includes the generation of FBOs, textures, etc. Lately, I've found myself needing to enhance this. The image generation ta...

Mutex protection for Singleton resources in multithreaded env

I have a server listening on a port for request. When the request comes in, it is dispatched to a singleton class Singleton. This Singleton class has a data structure RootData. class Singleton { void process(); void refresh(); private: RootData mRootData; } In the class there are two functions: process: Work with the mRo...

How to stop threads when undeploying a JEE application?

I undeploy my JEE app that uses an asynchronous logger that logs in its own thread from the Drools rules engine. I use it to log decisions the rules engine makes but I cannot let it have impact on the throughput, therefore it must run in its own thread. I get pages of Exceptions when I undeploy it indicating that it was not closed prope...

Writing Objects from a thread in Android

I have a game object that I save like this in OnPause() try { final ObjectOutputStream os = new ObjectOutputStream(openFileOutput(gameName + ".sav", 0)); os.writeObject(gameObject); os.reset(); } catch (final Exception e) { e.printStackTrace(); } This works fine except on some of the older or slower phones it can someti...

Binding specific threads to specific processor cores

I've word a bit with parallel processing in college and now I'm trying to get better at it. I can write code that can run in parallel and then start up threads, but after that I loose control over what the threads do. I would like to know how I can control the threads to things like for example bind a specific thread to a specific proces...

Reasons for an iOS thread to exit prematurely?

I have a block of code in my iOS app that fills an array with Core Data objects on a background thread, via NSOperationQueue, then notifies the UI on the main thread when it completes. Everything has worked perfectly in iOS3. However, in my new iOS4 build, I started noticing an occasional bug where the UI never gets notified that the da...

Java Concurrency JDK 1.6: Busy wait does better than signalling? Effective Java #51

Joshua Bloch's "Effective Java", Item 51 is not about depending on the thread scheduler as well as not keeping threads unnecessarily in the runnable state. Quoted text: The main technique for keeping the number of runnable threads down is to have each thread do a small amount of work and then wait for some condition using Object.w...

java multi thread access to primitive variables

Hi - I know that concurrently accessing the same object from different threads, without synchronisation, is in general a bad thing. But what about this case: I have multiple threads running (consider two, ThreadA & ThreadB). I also have this static class to keep count of the number of times a Thread does something. public class Counter...

How does a Timer Elapsed event compete with High Priority threads?

I have a System.Timers.Timer object that I want to use, but I don't want the processing tied to the Timer to interfere with normal to high priority threads. In other words, I'd like to say that I want to process X every 5 seconds as long as nothing else is running. How could I ensure that my Timer operations are running in a low-priori...

Multithreading and Thead pools- Need Design suggestion

I want to implement something like this. 1.A background process which will be running forever 2.The background process will check the database for any requests in pending state. If any found,will assign a separate thread to process the request.So one thread per request.Max threads at any point of time should be 10. Once the thread has ...

.NET parallel processing of ArrayList

Hello everyone, I am attempting at embedding multi-threading for the first time ever and running into some unexpected issues, hope you can help. Here's the code fragment that gives me troubles: ArrayList recordsCollection = new ArrayList(); ArrayList batchCollection = null; int idx = 0; while(true) { // Some code to generate and as...

TcpListener Timeout/about/something? Without ASync?

I create a thread which uses TcpListener and when my app closes i'd like the thead to terminate. I can call abort but the thread is still alive since TcpListener is blocking with AcceptTcpClient. Is it possible to about or set a timeout or to do SOMETHING with AcceptTcpClient? i cant imagine how it would be useful if theres no way to st...