FileDocCategorySizeDatePackage
Producer.javaAPI DocExample723Wed Feb 18 01:44:34 GMT 1998None

Producer

public class Producer extends Thread

Fields Summary
private Vector
messages
static int
MAXQUEUE
Constructors Summary
Methods Summary
public synchronized java.lang.StringgetMessage()

		notifyAll();
		while ( messages.size() == 0 )
			wait();
		String message = (String)messages.firstElement();
		messages.removeElement( message );
        return message;
    
private synchronized voidputMessage()

		while ( messages.size() == MAXQUEUE )
			wait();
		messages.addElement( new java.util.Date().toString() );
		notifyAll();
	
public voidrun()

 
       
		try {
			while ( true ) {
				putMessage();
				sleep( 1000 );
			}
		} catch( InterruptedException e ) { }