我使用CompletableFuture并行运行任务。不幸的是,除非我使用join,否则它不能工作。我对这种情况的发生感到惊讶,因为根据docs的说法,get在返回结果的类中也是一个阻塞方法。//cf.join(); if i uncommnet this everything works 如果我在方法processChunk中取消对上面一行的
在为必须首先加载到内存中的资源提供服务的类中,我的模式如下: private final CompletableFuture<Void> loadedsome task that shouldn't hold up constructing }
public Foo get(String bar) {this.loaded.join(); //