Example usage for java.util List notifyAll

List of usage examples for java.util List notifyAll

Introduction

In this page you can find the example usage for java.util List notifyAll.

Prototype

@HotSpotIntrinsicCandidate
public final native void notifyAll();

Source Link

Document

Wakes up all threads that are waiting on this object's monitor.

Usage

From source file:edu.eci.arsw.loannetsim.LoanNetworkSimulation.java

public static void main(String args[]) throws InterruptedException, IOException {
    ApplicationContext ac = new ClassPathXmlApplicationContext("applicationContext.xml");

    int balancesSum = 0;

    List<Lender> lenders = setupLoanNetwork(NUMOF_LENDERS, ac);

    if (lenders != null) {
        for (Lender im : lenders) {
            new Thread(im).start();
        }//from w  w w.  ja  v  a  2s.c  o m
    }

    while (true) {
        Thread.sleep(10000);

        FixedMoneyLender.pause();

        System.out.println("*** PRESS ENTER TO VIEW STATISTICS ***");

        System.in.read();

        balancesSum = 0;
        for (Lender ln : lenders) {
            balancesSum += ln.getBalance();
        }

        System.out.println("Sum of balances:" + balancesSum);

        System.out.println("Press enter to continue simulation or Ctrl+C to abort...");

        System.in.read();

        FixedMoneyLender.resume();
        synchronized (lenders) {
            lenders.notifyAll();
        }

    }

}

From source file:org.apache.hadoop.mapred.CoronaJobHistory.java

private static void closeAndClear(List<PrintWriter> writers) {
    for (PrintWriter out : writers) {
        out.close();//w w w .  j  a  v a  2  s  .  co  m
    }
    // By clearning the writers and notify the thread waiting on it, 
    // we will prevent JobHistory.moveToDone() from
    // waiting on writer
    synchronized (writers) {
        writers.clear();
        writers.notifyAll();
    }
}

From source file:org.commonreality.participant.impl.RequestableObjectManagerDelegate.java

/**
 * When a new block of identifiers is made available from CR, they are added
 * to the object manager//from  www  .j a va  2s. c o  m
 * 
 * @param freeIdentifiers
 */
final public void addFreeIdentifiers(Collection<IIdentifier> freeIdentifiers) {
    if (LOGGER.isDebugEnabled())
        LOGGER.debug("Adding free identifiers " + freeIdentifiers);
    for (IIdentifier freeId : freeIdentifiers) {
        Object key = getKey(freeId);
        if (key == null)
            continue;

        List<IIdentifier> keyedIdentifiers = getKeyedCollection(key);
        /*
         * add it.. and signal
         */
        synchronized (keyedIdentifiers) {
            keyedIdentifiers.add(freeId);
            keyedIdentifiers.notifyAll();
        }
    }
}