@Override
  public void run() {
    while (true) {
      in.pop();

      /*try {
      	Thread.sleep(5); // Man it's hard generating random numbers.
      } catch (InterruptedException e) {
      	// TODO Auto-generated catch block
      }*/

      // Branching factor 10
      for (int i = 0; i < 10; i++) out.add(Math.random());
    }
  }
示例#2
0
 @Override
 public void run() {
   while (isAlive) {
     try {
       KTask toExecuteTask = null;
       if (toExecuteTask == null) {
         toExecuteTask = tasks.poll();
       }
       if (toExecuteTask != null) {
         try {
           toExecuteTask.run();
         } catch (Exception e) {
           e.printStackTrace();
         }
       } else {
         try {
           Thread.sleep(20 * _nbWorker);
         } catch (InterruptedException e) {
           e.printStackTrace();
         }
       }
     } catch (Exception e) {
       e.printStackTrace();
     }
   }
 }
示例#3
0
 @Override
 public void dispatch(KTask task) {
   tasks.offer(task);
 }