Package org.akka.essentials.stm.stockticker.example

Source Code of org.akka.essentials.stm.stockticker.example.StockApplication

package org.akka.essentials.stm.stockticker.example;

import akka.actor.ActorSystem;
import akka.agent.Agent;

public class StockApplication {

  public static void main(String[] args) throws Exception {
    ActorSystem _system = ActorSystem.create("Agent-example");
    Stock stock = new Stock("APPL", new Agent<Float>(new Float("600.45"),
        _system));

    Thread[] readerThreads = new Thread[10];
    Thread[] updateThreads = new Thread[5];
    for (int i = 0; i < 10; i++) {
      readerThreads[i] = new Thread(new StockReader(stock));
      readerThreads[i].setName("#" + i);
    }
    for (int i = 0; i < 5; i++) {
      updateThreads[i] = new Thread(new StockUpdater(stock));
      updateThreads[i].setName("#" + i);
    }
    for (int i = 0; i < 10; i++)
      readerThreads[i].start();

    for (int i = 0; i < 5; i++)
      updateThreads[i].start();

    Thread.sleep(3000);
    _system.shutdown();

  }
}
TOP

Related Classes of org.akka.essentials.stm.stockticker.example.StockApplication

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.