001package horstmann.ch09_greeting;
002/**
003   An action that repeatedly prints a greeting.
004 */
005public class GreetingProducer implements Runnable
006{
007        /**
008      Constructs the producer object.
009      @param aGreeting the greeting to display
010         */
011        public GreetingProducer(String aGreeting)
012        {
013                greeting = aGreeting;
014        }
015
016        public void run()
017        {
018                try
019                {
020                        for (int i = 1; i <= REPETITIONS; i++)
021                        {
022                                System.out.println(i + ": " + greeting);
023                                Thread.sleep(DELAY);
024                        }
025                }
026                catch (InterruptedException exception)
027                {
028                }
029        }
030
031        private String greeting;
032
033        private static final int REPETITIONS = 10;
034        private static final int DELAY = 100;
035}