コード例 #1
0
 public void syncFlushPacketQueue(MCCraftPacket[] packetWrappers) {
   while (!resyncQueue.isEmpty()) {
     Packet p = resyncQueue.pollFirst();
     if (p != null) {
       syncedSendPacket(p, packetWrappers);
     }
   }
 }
コード例 #2
0
  public static void main(String[] args) {
    if (args.length < 2) System.exit(1);
    if (args.length > 2) {
      callMainSearch(args[1]);
      System.exit(1);
    }
    try {
      Indexer indexer = new Indexer(new File(args[1]));
      IndexerPool.addIndexer(indexer);
    } catch (Exception e) {
      e.printStackTrace();
      System.exit(1);
    }
    String[] sfxes = {".PDF", ".pdf"};
    Collection<File> files = FileSystemUtils.getFiles(args[0], sfxes);
    LinkedList<TextExtractorRunner> extractorRunners = new LinkedList<TextExtractorRunner>();
    LinkedList<Thread> threads = new LinkedList<Thread>();
    LinkedBlockingDeque<File> queue = new LinkedBlockingDeque<File>();
    int i = 0;
    while (i++ < 8) {
      extractorRunners.add(new TextExtractorRunner(new TextExtractor(), queue));
    }

    Iterator<TextExtractorRunner> rit = extractorRunners.iterator();
    while (rit.hasNext()) {
      Thread t = new Thread(rit.next());
      threads.add(t);
      t.start();
    }

    for (File f : files) {
      queue.offer(f);
    }
    while (true) {
      if (queue.isEmpty()) {
        break;
      }
      Utility.Sleep(100);
    }

    rit = extractorRunners.iterator();
    while (rit.hasNext()) {
      rit.next().stop();
    }

    Iterator<Thread> thIt = threads.iterator();
    while (thIt.hasNext()) {
      try {
        thIt.next().join();
      } catch (InterruptedException e) {
        e.printStackTrace();
      }
    }

    System.out.println("Done ....................");
  }