org.qbicc.machine.tool.process.CloseableThread Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of qbicc-machine-tool-api Show documentation
Show all versions of qbicc-machine-tool-api Show documentation
The API for Qbicc machine tooling support
package org.qbicc.machine.tool.process;
import java.io.IOException;
import io.smallrye.common.function.ExceptionRunnable;
final class CloseableThread extends Thread {
private final ExceptionRunnable runnable;
Throwable problem;
CloseableThread(final String name) {
this(name, () -> {});
}
CloseableThread(final String name, final ExceptionRunnable runnable) {
super(name);
this.runnable = runnable;
}
public final void run() {
try {
runWithException();
} catch (Throwable t) {
problem = t;
}
}
void runWithException() throws IOException {
runnable.run();
}
}