私はいくつかのコードを勉強していますが、ここにメソッドがありますが、それが何をするのかよくわかりません:
1) がありますが、なぜRunnableFuture
が割り当てられているのですか?FutureTask
FutureTask = new Futuretask
2) の意味はnew SortProcessor<E>
、Java または別のクラスからのものです。
public synchronized void sort() {
if (this.internalState == InternalState.READ) throw new IllegalStateException();
final RunnableFuture<E> leftFuture = new FutureTask<E>(new SortProcessor<E>(this.leftChild));
final RunnableFuture<E> rightFuture = new FutureTask<E>(new SortProcessor<E>(this.rightChild));
new Thread(leftFuture, "left-child").start();
new Thread(rightFuture, "right-child").start();
try {
this.leftCache = leftFuture.get();
this.rightCache = rightFuture.get();
} catch (final InterruptedException interrupt) {
throw new ThreadDeath();
} catch (final ExecutionException exception) {
final Throwable cause = exception.getCause();
if (cause instanceof Error) throw (Error) cause;
if (cause instanceof RuntimeException) throw (RuntimeException) cause;
throw new AssertionError();
}
if (this.leftCache != null | this.rightCache != null) {
this.internalState = InternalState.READ;
}
}