[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Condor-users] multi-threaded java application



I'm fairly new to Condor, so I apologize if this is a question that has been answered before, but I have been unable to find any information on it.
 
Here's our setup:  We're running condor on a grid.  We have a bunch of blades - each blade has 2 processors and each processor has 4 cores.  Each core is set up as a compute node. 
 
We submit a java job running multiple threads.  It seems like once the main thread finishes, the job returns, without waiting for any other threads to finish.  the following java code yields the following output:
 
package threadtester;

public class Main implements Runnable {
   
    private int threadNum;
   
    private Main(int i) {
        threadNum = i;
    }

    public static void main(String[] args) {
        if(args.length != 1){
            System.out.println("The command line arguments should contain a single number, the number of threads to run.");
        }
        int numThreads = Integer.parseInt(args[0]);
        for(int i = 0; i < numThreads; i++){
            Thread t = new Thread(new Main(i));
            t.start();
        }
    }
 
    public void run() {
        for(int i = 0; i < 10; i++){
            try {
                System.out.println("Thread " + threadNum + ": " + i);
                Thread.sleep(500);
            } catch (InterruptedException ex) {
                System.out.println("Thread interrupted.");
                System.exit(1);
            }
        }
    }
}
 
The output (when run with an argument of 5 and run on the grid), is simply
Thread 0: 0
Thread 1: 0
Thread 2: 0
Thread 3: 0
Thread 4: 0
Thread 5: 0
 
When this same program is run on a workstation (no condor), we get the expected result of
Thread 0: 0
Thread 1: 0
Thread 2: 0
Thread 3: 0
Thread 4: 0
Thread 5: 0
Thread 0: 1
Thread 1: 1
Thread 2: 1
Thread 3: 1
Thread 4: 1
Thread 5: 1
... 10 times.
 
If a barrier is put into place, which stalls the main thread until all of the other threads finish, it works fine.  Has anyone encountered this before?  Any help is greatly appreciated.
 
Thanks,
 
Josh