This is the mail archive of the
java-discuss@sourceware.cygnus.com
mailing list for the Java project.
Re: Thread.sleep() and problems with jlong within native code on glibc
- To: bryce@albatross.co.nz
- Subject: Re: Thread.sleep() and problems with jlong within native code on glibc
- From: Andrew Haley <aph@pasanda.cygnus.co.uk>
- Date: 14 Jun 1999 15:32:25 -0000
- CC: java-discuss@sourceware.cygnus.com
> Date: Mon, 14 Jun 1999 15:30:56 +1200
> From: Bryce McKinlay <bryce@albatross.co.nz>
>
> --------------63BC43B582EAA9799DE8A966
> Content-Type: text/plain; charset=us-ascii
> Content-Transfer-Encoding: 7bit
Please, no more MIME.
> I have been investigating the problem of Thread.sleep() not working on
> linux/glibc.
>
> There is some kind of problem with the jlong value returned by
> System::currentTimeMillis() when it is called from within native code.
> The System::currentTimeMillis() result seen is wrong -
> currentTimeMillis() / 1000 is much smaller than the tv_sec value
> returned from gettimeofday. However, when System.currentTimeMillis() is
> called from within Java code, it works fine.
>
> The patch below works around the problem by avoiding the call to
> currentTimeMillis(), and fixed Thread.sleep() on Linux. I have not
> committed it to cvs, yet, because this patch is really just fixing the
> symptom and not the problem.
>
> Clues?
Sure. Look at this:
> - unsigned long m = millis + java::lang::System::currentTimeMillis
I think there's an overflow here: this should be a long long or a
jlong, not a long.
Andrew.