Thread: Time
View Single Post
  #4 (permalink)  
Old 09-07-2008, 03:30 AM
Supamagier Supamagier is offline
Senior Member
 
Join Date: Aug 2008
Posts: 186
Supamagier is on a distinguished road
if you are using threads:
Code:
import java.applet.*; import java.awt.*; public class TimerTest extends Applet implements Runnable { final Thread timer; final int cycletime = 1000; public void init() { setSize(500,500); timer = new Thread(this); timer.start(); } public void run() { while (true) { // Do things here try { timer.sleep(cycletime); } catch (InterruptedException ie) { System.out.println("ERROR sleeping"); } } } }
I prefer Threads, they're easier.

to stop the above Thread: timer.stop() (deprecated) or timer = null
__________________
check out
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
, 100% made by me.
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Reply With Quote