multithreading

Why do some JVM/Linux Kernels show each java thread as a process and other not? How can I determine beforehand what the behavior will be?

I have two machines, one running 2.4.18 and one running 2.4.20. Both run Java 1.5 build 13. On one machine (2.4.18), each thread shows up as a separate process in the ps output, and on the other the whole JVM shows up as one process. What is the distinguishing factor and can I control it? ...

java detect no other threads are in an object

I am writing a class (Foo) which, when instantiated, can be called from multiple threads. Most methods of the Foo class can safely be called by multiple threads in parallel. One method of this class (logout()), requires that all other threads are done. Before logout is called, the reference to foo is deleted from a thread-safe collect...

Java object implements Runnable, how to remove the object from a collection

I have a java object that implements Runnable. here is the code. public class Obj implements Runnable { boolean shouldRun; private int stuff public Obj() { this.setshouldRun(true); stuff = 0; } public synchronized void setshouldRun(boolean shouldRun) { this.shouldRun = shouldRun; } public ...

How do I limit the number of active threads in python ?

Am new to python and making some headway with threading - am doing some music file conversion and want to be able to utilize the multiple cores on my machine (one active conversion thread per core). class EncodeThread(threading.Thread): # this is hacked together a bit, but should give you an idea def run(self): decode ...

How do I Understand Read Memory Barriers and Volatile

Some languages provide a volatile modifier that is described as performing a "read memory barrier" prior to reading the memory that backs a variable. A read memory barrier is commonly described as a way to ensure that the CPU has performed the reads requested before the barrier before it performs a read requested after the barrier. Howe...

How many threads to create?

Hello everyone, I am just learning how to write mutithreaded programs right now and I have a hypothetical question about how many threads are optimal for a program. Let me describe 2 scenarios. The first scenario is that i have a program that is easily multi threaded but each thread is going to be doing a lot of work (execution time...

AutoResetEvent clarification

I want to clarify how the following code works.I have itemized my doubts to get your reply. class AutoResetEventDemo { static AutoResetEvent autoEvent = new AutoResetEvent(false); static void Main() { Console.WriteLine("...Main starting..."); ThreadPool.QueueUserWorkItem (new WaitCallback(CodingInCS...

Lazy sockets - scalability?

Asking more in theory, how could I build a server (or app) that uses lazy sockets? I'm envisioning a web app that moves all of its data via JSON exchanges to a central API-like servlet. I could leave the HTTP connection open for a bit after transferring all data, to write more to the client, as a sort of lazy push technology. The browser...

C# -Fiinding available Threads

Normally I heard that 25 threads are operating on ThreadPool. When I execute the following : namespace Examples.Delegates { public delegate void InvokerDelegate(); class Discussion { static void Main() { Discussion dis=new Discussion(); InvokerDelegate MethodInvoker=dis.Foo; ...

Sending message to different thread

Is there any API to send message to a thread? Basically I have only threadId available and I want to send a custom message to that thread. ...

Windows Service suddenly doing nothing

Hi, My windows service is using a Thread (not a timer) which is always looping and sleeps for 1 second every loop using : evet.WaitOne(interval); When I start the service it works fine and I can see in the task manager that it is running, consuming and releasing memory, consuming processor ... etc that is all normal, but after a while (...

Determine Child Processes for Thread or Appdomain

I'm using a 3rd party assembly to do some processing, and it spawns 2 child processes to perform some work. I'm running this in a separate thread. I want to be able to cancel the processing if it runs for too long - my problem is that if I abort the thread the spawned processes are still running. Is there a way to determine what proces...

http listeners inside threads

Hello I am writing a web service which has to be able to reply to multiple http requests. From what I understand, I will need to deal with HttpListener. What is the best method to receive a http request(or better, multiple http requests), translate it and send the results back to the caller? How safe is to use HttpListeners on threads?...

Creating Threaded callbacks in XS

EDIT: I have created a ticket for this which has data on an alternative to this way of doing things. I have updated the code in an attempt to use MY_CXT's callback as gcxt was not storing across threads. However this segfaults at ENTER. #include "EXTERN.h" #include "perl.h" #include "XSUB.h" #ifndef aTHX_ #define aTHX_ #endif #ifdef...

"Time out" when multithreading requests to a webservice with java and axis2

Hi, I'm working with a slow webservice (about 4 minutes each request) and I need to do about 100 requests in two hours, so I've decided to use multiple threads. The problem is that I can only have 2 threads, as the stub rejects all the other ones. Here I've found an explanation and possible solution: I had the same problem. It seems...

How to kill main thread from sub thread in Jython

I have a script that creates a thread which after 60 seconds (this thread) needs to kill the main thread. I`m not sure what command I can use to kill the main thread. I'm using Jython 2.5.1 and Thread.interrupt_main doesn't work. Here is the code: import threading def exitFunct(): #exit code here t = threading.Timer(60.0, exitFunc...

Multithreaded access to the WPF GUI in C#

Hello, I'm trying to create a custom, in-house application that is going to access other internal systems which broadcast their names and IP addresses via UDP. I'm trying to create a multi-threaded dialog that polls for UDP messages every 500 ms for 15 seconds, parses the UDP messages and then adds the names of the detected systems to ...

What happens when object running thread A is destroyed by thread B?

I may be greatly misunderstanding this threading scenario, but that's why I'm asking. What would/might happen in the following situation (assume C# threading)? Note: this scenario is simplified to the core issue, extra functionality is ignored. I have 2 objects, a and b, which are instances of classes A and B respectively; 'b' is a me...

Threading Web requests handled in Main?

I'm writing an application in C#, and I am creating multiple BackgroundWorker threads to grab information from webpages. Despite them being BackgroundWorkers, my GUI Form is becoming unresponsive. When I am debugging, I pause when the program goes unresponsive, and I can see that I am in the Main Thread, and I am paused on the webpage ...

CUDA - Better Occupancy vs Less Global Memory Access?

Hey My CUDA code must work with (reduce to mean/std, calculate histogram) 4 arrays, each 2048 floats long and already stored in the device memory from previous kernels. It is generally advised to launch at least as many blocks as I have multiprocessors. In this case however, I can load each of these arrays into the shared memory of a ...