Example #1
0
 @Override
 public void run() {
   while (true) {
     try {
       Thread.sleep(2000);
     } catch (InterruptedException e) {
       // TODO Auto-generated catch block
       e.printStackTrace();
     }
     products.suply();
   }
 }
Example #2
0
    @Override
    public void run() {
      Random rand = new Random();
      List<String> stocks = new ArrayList<String>();
      for (TreeMap<String, Integer> e : products.getProducts().values()) {
        for (Entry<String, Integer> entry : e.entrySet()) {
          stocks.add(entry.getKey());
        }
      }

      while (true) {
        try {
          Thread.sleep(400);
        } catch (InterruptedException e) {
          // TODO Auto-generated catch block
          e.printStackTrace();
        }
        String product = stocks.get(rand.nextInt(9));
        shop.sellProduct(product);
      }
    }