-
Notifications
You must be signed in to change notification settings - Fork 4
Closed
Labels
bugSomething isn't workingSomething isn't working
Description
Summary
SemaphoreExecutor fails to execute a Runnable tasks
Expected Output
10 x Task is running System.out prints
10 x Task completed System.out prints
Actual Output
no System.out prints
Test Code
import io.github.thunkware.vt.bridge.ExecutorTool;
import io.github.thunkware.vt.bridge.SemaphoreExecutor;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Future;
public class ExecutorServiceExample {
public static void main(String[] args) {
ExecutorService executor = new SemaphoreExecutor(ExecutorTool.newVirtualThreadPerTaskExecutor(), 2);
List<Future<?>> futures = new ArrayList<>();
for (int i = 0; i < 10; i++) {
Future<?> future = executor.submit(new RunnableTask());
futures.add(future);
}
for (Future<?> future : futures) {
try {
future.get();
} catch (Exception e) {
e.printStackTrace(System.err);
}
}
executor.shutdown();
}
private static class RunnableTask implements Runnable {
@Override
public void run() {
System.out.println("Task is running");
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
}
System.out.println("Task completed");
}
}
}Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working