Hi all,

I want to print some numbers, say starting from 1 and increment by 1, in a specific interval, say each one second.

I want to use Java thread to do this. Can you guys give me a clue.

I've try this, but I can't execute on main(). When I call the init() method, thread stopped.

Code:
public class Counter extends Applet implements Runnable {
	Thread t;	
	int Count;

    @Override
	public void init()	
	{	
		Count=0;
		t=new Thread(this);
		t.start();
	}

    @Override
	public boolean mouseDown(Event e,int x, int y)
	{	
		t.stop();
		return true;
	}

	public void run()
	{
		while(true)
		{
			Count++;
			repaint();
			try {
				Thread.sleep(10);
			} catch (InterruptedException e) {}
		}
	}

    @Override
	public void paint(Graphics g)
	{
		//g.drawString(Integer.toString(Count),10,10);
		System.out.println("Count= "+Count);
	}

    @Override
	public void stop()
	{
		t.stop();
	}
}

public class Main {
    public static void main(String[] args) {
         
        Counter ss = new Counter();
        ss.run();
    }

}
Thanks.