initAndPushStock();
}
private void initAndPushStock() {
for (int i = 0; i < 6; i++) {
stocks.add(new PonyStock(id.incrementAndGet(), "Altai horseBengin v" + i, 5.5f, 100));
stocks.add(new PonyStock(id.incrementAndGet(), "American Warmblood v" + i, 10f, 100));
stocks.add(new PonyStock(id.incrementAndGet(), "Falabella v" + i, 15f, 100));
stocks.add(new PonyStock(id.incrementAndGet(), "Friesian horse v" + i, 20f, 100));
stocks.add(new PonyStock(id.incrementAndGet(), "Mustang v" + i, 30f, 100));
stocks.add(new PonyStock(id.incrementAndGet(), "Altai horse v" + i, 50f, 100));
}
final Executor executor = Executors.newSingleThreadExecutor();
executor.execute(new Runnable() {
@Override
public void run() {
final Random rdm = new Random();
while (true) {
try {
final int index = rdm.nextInt(stocks.size());
final float newPrice = rdm.nextFloat() * 100;
final PonyStock stock = stocks.get(index);
stock.setPrice(newPrice);
pushData(stock);
Thread.sleep(1000);
} catch (final Exception e) {
log.error("", e);
}