01
02
03
04
05
06
07
08
09
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
package horstmann.ch09_greeting;
/**
   An action that repeatedly prints a greeting.
 */
public class GreetingProducer implements Runnable
{
  /**
      Constructs the producer object.
      @param aGreeting the greeting to display
   */
  public GreetingProducer(String aGreeting)
  {
    greeting = aGreeting;
  }

  public void run()
  {
    try
    {
      for (int i = 1; i <= REPETITIONS; i++)
      {
        System.out.println(i + ": " + greeting);
        Thread.sleep(DELAY);
      }
    }
    catch (InterruptedException exception)
    {
    }
  }

  private String greeting;

  private static final int REPETITIONS = 10;
  private static final int DELAY = 100;
}