/** * Returns the next available thread id. Subclasses may wish to * override this, for example if they implement a timeout */ Integer getProcessor() { try { return idleProcessors.take(); } catch (InterruptedException e) { throw new RuntimeInterruptedException(e); } }
public static void checkForInterrupt() { if (Thread.interrupted()) { throw new RuntimeInterruptedException(); } }
@Override protected Integer getProcessor() { try { return (timeout <= 0) ? idleProcessors.take() : idleProcessors.poll(timeout, TimeUnit.MILLISECONDS); } catch (InterruptedException e) { throw new RuntimeInterruptedException(e); } }
private static void robustCreateFile(File candidate) throws IOException { int tries = 0; while ( ! candidate.exists()) { if (tries > 30) { throw new IOException("Could not create file: " + candidate); } if (candidate.createNewFile()) { break; } tries++; try { Thread.sleep(1000); } catch (InterruptedException e) { log(e); throw new RuntimeInterruptedException(e); } } }
@Override public Collection<SequencePattern<T>> apply(List<? extends T> elements) { // Use LinkedHashSet to preserve original ordering of patterns. Set<SequencePattern<T>> triggeredPatterns = new LinkedHashSet<>(); for (T node:elements) { if (Thread.interrupted()) { // Allow interrupting throw new RuntimeInterruptedException(); } Collection<SequencePattern<T>> triggered = trigger.apply(node); triggeredPatterns.addAll(triggered); } return triggeredPatterns; } }
/** Fills in the iScore array of each category over each span * of length 2 or more. */ void doInsideScores() { for (int diff = 2; diff <= length; diff++) { if (Thread.interrupted()) { throw new RuntimeInterruptedException(); } // usually stop one short because boundary symbol only combines // with whole sentence span. So for 3 word sentence + boundary = 4, // length == 4, and do [0,2], [1,3]; [0,3]; [0,4] for (int start = 0; start < ((diff == length) ? 1: length - diff); start++) { doInsideChartCell(diff, start); } // for start } // for diff (i.e., span) } // end doInsideScores()
@Override public int addToIndex(E o) { Integer index = indexes.get(o); if (index == null) { if ( ! locked) { try { semaphore.acquire(); index = indexes.get(o); if (index == null) { index = objects.size(); objects.add(o); indexes.put(o, index); } semaphore.release(); } catch (InterruptedException e) { throw new RuntimeInterruptedException(e); } } else { return -1; } } return index; }
public void close() throws IOException { process.getOutputStream().close(); try { outGobbler.join(); errGobbler.join(); outGobbler.getOutputStream().close(); process.waitFor(); } catch (InterruptedException ex) { throw new RuntimeInterruptedException(ex); } //log.info("getBZip2PipedOutputStream: Closed. "); } }
throw new RuntimeInterruptedException(e);
Thread.sleep(100); } catch (InterruptedException e) { throw new RuntimeInterruptedException(e);
} catch (InterruptedException e) { System.err.printf("%s: tar did not return from building %s.tar\n", this.getClass().getName(),distribName); throw new RuntimeInterruptedException(e);
public void annotate(final Annotation annotation, final Consumer<Annotation> callback){ if (PropertiesUtils.getInt(properties, "threads", 1) == 1) { annotate(annotation); callback.accept(annotation); } else { try { availableProcessors.acquire(); } catch (InterruptedException e) { throw new RuntimeInterruptedException(e); } new Thread(() -> { try { annotate(annotation); } catch (Throwable t) { annotation.set(CoreAnnotations.ExceptionAnnotation.class, t); } callback.accept(annotation); availableProcessors.release(); }).start(); } }
exec.awaitTermination(Long.MAX_VALUE, TimeUnit.SECONDS); } catch (InterruptedException e) { throw new RuntimeInterruptedException(e);
public void run() { Runtime runtime = Runtime.getRuntime(); timer.start(); while (true) { peak = Math.max(peak, runtime.totalMemory() - runtime.freeMemory()); if (timer.report() > logFrequency) { log(); timer.restart(); } try { Thread.sleep(pollFrequency); } catch (InterruptedException e) { log(); throw new RuntimeInterruptedException(e); } } }
throw new RuntimeInterruptedException(e);
Thread.sleep(100); } catch (InterruptedException e) { throw new RuntimeInterruptedException(e);
for(int i = s; i < regionEnd; i++){ if (Thread.interrupted()) { throw new RuntimeInterruptedException();
private void runTagInference() { this.initializeScorer(); if (Thread.interrupted()) { // Allow interrupting throw new RuntimeInterruptedException(); } BestSequenceFinder ti = new ExactBestSequenceFinder(); //new BeamBestSequenceFinder(50); //new KBestSequenceFinder() int[] bestTags = ti.bestSequence(this); finalTags = new String[bestTags.length]; for (int j = 0; j < size; j++) { finalTags[j] = maxentTagger.tags.getTag(bestTags[j + leftWindow()]); } if (Thread.interrupted()) { // Allow interrupting throw new RuntimeInterruptedException(); } cleanUpScorer(); }
pool.awaitTermination(Long.MAX_VALUE, TimeUnit.NANOSECONDS); } catch (InterruptedException e) { throw new RuntimeInterruptedException(e);