Find the cancellation bug in this virtual-thread task.
Java
public class StockWait {
static void waitForStock() {
try {
Thread.sleep(1_000);
} catch (InterruptedException ignored) {
System.out.println("retrying");
}
}
public static void main(String[] args) throws Exception {
var worker = Thread.startVirtualThread(StockWait::waitForStock);
worker.interrupt();
worker.join();
}
}