Date: Wed, 14 Aug 2002 10:35:15 -0600 From: Nate Williams <nate@yogotech.com> To: Huang wen hui <hwh@ns.gddsn.org.cn> Cc: "Bill Huey (Hui)" <billh@gnuppy.monkey.org>, java <java@FreeBSD.ORG> Subject: Re: Hotspot vm is extremely slower than nojit vm on current ? Message-ID: <15706.34499.692329.335121@emerger.yogotech.com> In-Reply-To: <3D5A0EBC.9060706@mail.gddsn.org.cn> References: <3D59C6A4.5020708@mail.gddsn.org.cn> <20020814030231.GA4285@gnuppy.monkey.org> <3D5A0EBC.9060706@mail.gddsn.org.cn>
next in thread | previous in thread | raw e-mail | index | archive | help
> >>Mostly hotspot vm is stable and fast, but I got problem with Thread.sleep. > >>Look at the following simple program, on current hotspot vm is extreamly > >>slow. This is probably unrelated, but you should note that you need to use synchronization on bQuit in order for it to be safely set. Otherwise, it is OK for the Timer thread to cache it's value (set to FALSE) and continue to use that value, so it may not pick up the new setting when you want it to. public class Timer extends Thread { private static ThreadGroup tGroup = new ThreadGroup("Timer"); // Number of seconds in each timer cycle int m_cycle; private Object quitLock = new Object(); private boolean bQuit = false; public Timer(int cycle) { super(tGroup,"TimerThread"); m_cycle = cycle; } public void run() { this.setName("TimerThread"); // Loop until stopped while (!done()) { try { // Sleep for the clock cycle sleep(m_cycle * 1000); } catch (InterruptedException ex) { // Ignored } // Fire a TimerEvent if (m_timerListener != null) { m_timerListener.TimerEvent(m_object); } } public void quit() { synchronized (quitLock) { bQuit = true; } } private boolean done() { synchronized (quitLock) { return (bQuit); } } Nate 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?15706.34499.692329.335121>