public void run() {
    try {
      while (!stopped && !Thread.currentThread().isInterrupted()) {
        MapHost host = null;
        try {
          // If merge is on, block
          merger.waitForInMemoryMerge();

          // Get a host to shuffle from
          host = scheduler.getHost();
          metrics.threadBusy();

          // Shuffle
          copyFromHost(host);
        } finally {
          if (host != null) {
            scheduler.freeHost(host);
            metrics.threadFree();
          }
        }
      }
    } catch (InterruptedException ie) {
      return;
    } catch (Throwable t) {
      shuffle.reportException(t);
    }
  }
Пример #2
0
 public static void main(String[] argv) {
   String[] arr = {"hello", "world", "Beijing", "C++", "Python", "Java", "java"};
   Shuffle.shuffleArr(arr);
   for (String s : arr) {
     System.out.println(s);
   }
 }