I am having an odd error with Thread.sleep()
on Java. For some reason, when I call sleep on some machines, it never returns. I can't figure out what could be causing this behaviour. At first, I thgouth the error might be elsewhere in my code, so I made the simplest possible sleep test:
public class SleepTest {
public static void main (String [] args) {
System.out.println ("Before sleep...");
try {
Thread.sleep (100);
} catch (InterruptedException e) {
}
System.out.println ("After sleep...");
}
}
On most machines it works, but on several machines which I am remotely logging into, it pauses indefinitely between the print statements. I have waited up to a half an hour with no change in behaviour. The machines that are displaying this error are Linux machines. Here is some information about the machines:
$ uname -a
Linux zone29ea 2.6.32-220.17.1.el6.x86_64 #1 SMP Tue May 15 17:16:46 CDT 2012 x86_64 x86_64 x86_64 GNU/Linux
$ java -version
java version "1.6.0_22"
OpenJDK Runtime Environment (IcedTea6 1.10.6) (rhel-1.43.1.10.6.el6_2-x86_64)
OpenJDK 64-Bit Server VM (build 20.0-b11, mixed mode)
What could be causing this behaviour?
UPDATE
Revised version, which still never ends:
public class SleepTest {
public static void main (String [] args) {
new Thread () {
public void run () {
System.out.println ("Before sleep...");
try {
Thread.sleep (100);
} catch (InterruptedException e) {
e.printStackTrace ();
}
System.out.println ("After sleep...");
}
}.start();
}
}