From owner-freebsd-java Wed Aug 14 3:52:18 2002 Delivered-To: freebsd-java@freebsd.org Received: from mx1.FreeBSD.org (mx1.FreeBSD.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id EF62937B400 for ; Wed, 14 Aug 2002 03:52:12 -0700 (PDT) Received: from gnuppy.monkey.org (wsip68-15-8-100.sd.sd.cox.net [68.15.8.100]) by mx1.FreeBSD.org (Postfix) with ESMTP id 7B90E43E6E for ; Wed, 14 Aug 2002 03:52:12 -0700 (PDT) (envelope-from billh@gnuppy.monkey.org) Received: from billh by gnuppy.monkey.org with local (Exim 3.35 #1 (Debian)) id 17evkz-0001SW-00; Wed, 14 Aug 2002 03:52:05 -0700 Date: Wed, 14 Aug 2002 03:52:05 -0700 To: Huang wen hui Cc: java , "Bill Huey (Hui)" Subject: Re: Hotspot vm is extremely slower than nojit vm on current ? Message-ID: <20020814105205.GA5605@gnuppy.monkey.org> References: <3D59C6A4.5020708@mail.gddsn.org.cn> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <3D59C6A4.5020708@mail.gddsn.org.cn> User-Agent: Mutt/1.4i From: Bill Huey (Hui) Sender: owner-freebsd-java@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.org On Wed, Aug 14, 2002 at 10:55:32AM +0800, Huang wen hui wrote: Mabey I'm a bit slow right now, but I'm unsure what you're trying to do in this example concerning sleep ? Why is this commented out ? [example reformatted] > import java.util.*; > import cn.gd.util.Timer; > import cn.gd.util.TimerListener; > > import java.sql.*; > > public class TestTimer implements cn.gd.util.TimerListener { > > Timer timer = new Timer(this,20); > > public TestTimer() { > timer.start(); > } > > public synchronized void TimerEvent(Object object) {} > > public void destoryTimer() { > timer.quit(); > } > > public void query(){ > try { > Class.forName("org.gjt.mm.mysql.Driver").newInstance(); > > Connection conn = > DriverManager.getConnection("jdbc:mysql://localhost/seismic?user=test&password=test"); > String sql = "select * from station"; > Statement st = conn.createStatement(); > ResultSet rs = null; > > for(int i=0;i<100;i++) { > rs = st.executeQuery(sql); > while(rs.next()) { > String sta = rs.getString("sta"); > //System.out.println("sta is: "+sta); > } > rs.close(); > } > > st.close(); > conn.close(); > > } catch (Exception e) { > e.printStackTrace(); > } > } > > public static void main(String[] args) throws Exception { > TestTimer tt = new TestTimer(); > long now = new java.util.Date().getTime(); > //Thread.sleep(60*1000); > tt.query(); > System.err.println("query elapse time: "+ (new > java.util.Date().getTime() - now)); > tt.destoryTimer(); > } > } > > > public class Timer extends Thread { > private static ThreadGroup tGroup = new ThreadGroup("Timer"); > // TimerListener to receive TimerEvent notifications > TimerListener m_timerListener; > > // Number of seconds in each timer cycle > int m_cycle; > > // Object to be supplied with the TimerEvent notification > Object m_object; > private boolean bQuit = false; > > public Timer(TimerListener timerListener, int cycle) { > super(tGroup,"TimerThread"); > m_timerListener = timerListener; > m_cycle = cycle; > m_object = null; > } > > public Timer(TimerListener timerListener, int cycle, Object object) { > super(tGroup,"TimerThread"); > m_timerListener = timerListener; > m_cycle = cycle; > m_object = object; > } > > public void run(){ > this.setName("TimerThread"); > // Loop until stopped > while (!bQuit) { > try { > // Sleep for the clock cycle > sleep(m_cycle * 1000); > } catch (InterruptedException ex) {} > > // Fire a TimerEvent > if (m_timerListener != null) { > m_timerListener.TimerEvent(m_object); > } > } > } > > public void quit() { > bQuit = true; > } > } > > public interface TimerListener > { > void TimerEvent(Object object); > } To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-java" in the body of the message