I have a very simple program which spawns two threads. Running this using
native threads on JDK 1.1.7_v3 (Red Hat 6.0 w/glibc 2.1) on a 2-way 
SMP machine only allows one of the threads to run; the other doesn't
even appear to start!

Using green threads, one thread always runs while the other is starved.
This is "correct" behavior for green threads in this case. However, with
native threads one would expect both threads to run simultaneously. 

Using "top" shows that only one 'java' thread is running; there are
multiple additional 'java' threads which are all sleeping.

On JDK1.2 and the IBM JDK 1.1.6 this program works correctly, with two
running 'java' kernel threads.

Could this be a problem with glibc 2.1, or something similar?

The program is appended below. Compile and run it with:
        $ javac TestT.java
        $ java -native TestT


Thanks, 
Matt Welsh, [EMAIL PROTECTED]

--

import java.lang.*;

public class TestT implements Runnable {

  public void run() {
    int j=0, k=1;
    System.err.println("Thread " + Thread.currentThread().getName() + " going");

    for (int i=0; i<1000000000; i++) {
       if (i%1000000 == 0) {
           System.out.println(Thread.currentThread().getName() + ": " +i);
       }
       j= k*i;
       k+=i;
    }

  }
  public static void main(String args[]) {
    TestT a1 = new TestT();
    Thread foo1 = new Thread(a1, new String("thread 1"));
    TestT a2 = new TestT();
    Thread foo2 = new Thread(a2, new String("thread 2"));

    foo1.start();
    foo2.start();

    while (true) { try { Thread.sleep(1000); } catch (Exception e) {} }
  }
}


----------------------------------------------------------------------
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]

Reply via email to