FileDocCategorySizeDatePackage
Consumer.javaAPI DocExample1554Mon May 01 14:41:42 BST 2000None

Producer

public class Producer extends Thread

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

        notify(  );
        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(  ) );
        notify(  );
    
public voidrun()


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