This is the mail archive of the
java-prs@sourceware.cygnus.com
mailing list for the Java project.
Re: java.lang/76: wait(timeout) always throws exception
- To: tromey at cygnus dot com
- Subject: Re: java.lang/76: wait(timeout) always throws exception
- From: Bryce McKinlay <bryce at albatross dot co dot nz>
- Date: 25 Oct 1999 08:50:00 -0000
- Cc: java-prs at sourceware dot cygnus dot com,
- Reply-To: Bryce McKinlay <bryce at albatross dot co dot nz>
The following reply was made to PR java.lang/76; it has been noted by GNATS.
From: Bryce McKinlay <bryce@albatross.co.nz>
To: mike@pillim.demon.co.uk
Cc: java-gnats@sourceware.cygnus.com
Subject: Re: java.lang/76: wait(timeout) always throws exception
Date: Mon, 25 Oct 1999 21:43:25 +1300
Mike,
Both this bug and java.lang/77 are already fixed in cvs/snapshot
releases of libgcj.
regards
[ bryce ]
mike@pillim.demon.co.uk wrote:
> >Number: 76
> >Category: java.lang
> >Synopsis: wait(timeout) always throws exception
> >Confidential: no
> >Severity: serious
> >Priority: medium
> >Responsible: tromey
> >State: open
> >Class: sw-bug
> >Submitter-Id: net
> >Arrival-Date: Sun Oct 24 03:16:00 PDT 1999
> >Closed-Date:
> >Last-Modified:
> >Originator: Mike Moreton
> >Release: libgcj-2.95.1
> >Organization:
> >Environment:
> linux, posix threads
> >Description:
> If you call wait with a timeout, and the timeout expires,
> then you get an IllegalMonitorStateException. This is
> because java::lang::Object::wait interprets the ETIMEDOUT
> response as an error.
>
> The code attached works fine under Sun JDK 1.2.1, and causes
> the exception with libgcj
> >How-To-Repeat:
> public class TestWait{
> public static void main(String[] args) {
> (new Doit()).doit();
> }
>
> }
>
> class Doit {
> public synchronized void doit() {
> for (int i = 0; i < 10; i++) {
> System.out.println("i is now "+i);
> try {wait(100);
> } catch (InterruptedException e) {}
> }
> }
>
> }
> >Fix:
> In posix-threads.cc
> method _Jv_CondWait (_Jv_ConditionVariable_t *cv, _Jv_Mutex_t *mu,
> jlong millis, jint nanos)
> after the "r = pthread_cond_timedwait (cv, pmu, &ts);" line
> add the following:-
>
> /*
> * Timeouts shouldn't be reported as an error.
> */
> if (r == ETIMEDOUT) {
> r = 0;
> }
> >Release-Note:
> >Audit-Trail:
> >Unformatted: