Date: Tue, 30 May 2000 22:06:31 +0200 (MET DST) From: Christophe Colle <christophe.colle@telenet.be> To: freebsd-java@freebsd.org Subject: java_X version "1.1.8" stuck on BufferedReader.readLine Message-ID: <Pine.SO4.4.05.10005302157330.5672-100000@zeus>
next in thread | raw e-mail | index | archive | help
Hi,
I have a problem with jdk 1.1.8 on FreeBSD.. Apparently when doing a
readLine on a BufferedReader-object all my threads hang :-(
Consider the follwing part of java-code:
import java.lang.*;
import java.io.*;
class Clock extends Thread {
private Thread master;
private long timeout;
protected void sleepFor(long timeout) {
master=Thread.currentThread();
this.timeout=timeout;
this.start();
}
protected void clear() {
this.interrupt();
this.stop();
}
public void run() {
System.out.println("you should see mee running, but in jdk1.1.8 you don't see me :-(");
try {
this.sleep(timeout);
//you should see the following message, but you won't with jdb1.1.8 and freebsd
System.out.println("timed out... interrupting master thread");
master.interrupt();
} catch (InterruptedException e) {
System.out.println("I got terminated");
return;
} catch (Exception e) {
e.printStackTrace();
}
}
}
public class test {
void loop() {
BufferedReader in=new BufferedReader(new InputStreamReader(System.in));
while (true) {
String str="";
boolean timedout=false;
Clock alarm=new Clock();
try {
alarm.sleepFor(1000);
str=in.readLine();
alarm.clear();
} catch (IOException e) {
if (Thread.interrupted()) {
timedout=true;
System.out.println("interrupt ....");
} else {
e.printStackTrace();
System.exit(99);
}
}
if (timedout == false && str == null)
System.exit(0);
System.out.println("--- "+str);
}
}
static public void main(String args[]) {
new test().loop();
}
}
When I run this on a solaris machine I see the following output (paced
every second):
colle@olympus: java test
you should see mee running, but in jdk1.1.8 you don't see me :-(
timed out... interrupting master thread
interrupt ....
---
you should see mee running, but in jdk1.1.8 you don't see me :-(
timed out... interrupting master thread
interrupt ....
---
you should see mee running, but in jdk1.1.8 you don't see me :-(
timed out... interrupting master thread
interrupt ....
---
When doing the same on a FreeBSD machine:
bash-2.03$ java -version
java_X version "1.1.8"
bash-2.03$
bash-2.03$
bash-2.03$ java test
^Cbash-2.03$
nothing ... it gets stuck :-(
^Cbash-2.03$ uname -a
FreeBSD portable.is.cool 3.4-RELEASE FreeBSD 3.4-RELEASE #2: Sun Feb 621:39:44 CET 2000 root@portable.is.cool:/old/src-cvs/src/sys/compile/PORTABLE i386
What can I do to get this problem solved?
Thanks!
cc
---
you type win, but you lose
The Internet doesn't really need admins that are dumber than
the ones we have already.
----
Christophe Colle
Telenet, Liersesteenweg 4, 2800 Mechelen, Belgium
tel:+32(0)15.333.981
mailto:christophe.colle@telenet.be
http://krtkg1.rug.ac.be/~colle
To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-java" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.SO4.4.05.10005302157330.5672-100000>
