我正在使用JNI,当由于目标应用程序中的错误而发生崩溃时,会生成hs_err_pid*.log文件.我想更改存储该文件的默认位置.现在,通过搜索我明白这可以使用JVM参数-XX:ErrorFile来实现.
该文件说,该参数默认为./hs_err_pid <PID >.LOG
现在,当我覆盖默认值时,如何告诉JVM仍然在文件名中包含进程ID?我显然试图将targetDir/hs_err_pid <pid >.log作为命令行参数,但这导致整个参数被忽略(并且文件存储到默认位置,即工作目录).如果我只说targetDir/hs_err_pid.log文件存储在我想要的位置,但是没有将文件附加到进程ID.
任何建议,将不胜感激.
如javadoc中所述,当我使用CompletableFuture.allOf()组合独立的可完成期货时,在将所有期货提供给该方法之后,它不能可靠地完成。例如:
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutionException;
public class CompletableFutureTest {
public static void main(String[] args) throws ExecutionException, InterruptedException {
Runnable dummyTask = () -> {
try {
Thread.sleep(200);
} catch (InterruptedException ignored) {
}
};
CompletableFuture<Void> f1 = CompletableFuture.runAsync(dummyTask);
CompletableFuture<Void> f2 = CompletableFuture.runAsync(dummyTask);
CompletableFuture[] all = {f1, f2};
f1.whenComplete((aVoid, throwable) -> System.out.println("Completed f1"));
f2.whenComplete((aVoid, throwable) -> System.out.println("Completed f2"));
CompletableFuture<Void> allOf = CompletableFuture.allOf(all);
allOf.whenComplete((aVoid, throwable) -> {
System.out.println("Completed allOf");
}
);
allOf.join();
System.out.println("Joined");
}
}
Run Code Online (Sandbox Code Playgroud)
导致以下结果:
Completed f2
Joined
Completed allOf
Completed …Run Code Online (Sandbox Code Playgroud)