01: import java.util.Date;
02: 
03: /**
04:    A thread that repeatedly prints a greeting.
05: */
06: public class GreetingThread extends Thread
07: {
08:    /**
09:       Constructs the thread object.
10:       @param aGreeting the greating to display
11:    */
12:    public GreetingThread(String aGreeting)
13:    {
14:       greeting = aGreeting;
15:    }
16: 
17:    public void run()
18:    {
19:       try
20:       {
21:          for (int i = 1; i <= REPETITIONS; i++)
22:          {
23:             Date now = new Date();
24:             System.out.println(now + " " + greeting);
25:             sleep(DELAY);         
26:          }
27:       }
28:       catch (InterruptedException exception)
29:       {
30:       }
31:    }
32: 
33:    private String greeting;
34: 
35:    private static final int REPETITIONS = 10;
36:    private static final int DELAY = 1000;
37: }