Package com.ponysdk.sample.client.datamodel

Examples of com.ponysdk.sample.client.datamodel.PonyStock


        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);
                    }
View Full Code Here

TOP

Related Classes of com.ponysdk.sample.client.datamodel.PonyStock

Copyright © 2018 www.massapicom. 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.