Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions core/src/main/java/lucee/runtime/thread/ThreadUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@

public final class ThreadUtil {

private static final boolean ALLOW_FUTURE_THREADS = false;
// virtual threads are safe from Java 25+ (JEP 491: synchronized no longer pins virtual threads)
private static final boolean ALLOW_VIRTUAL_THREADS = SystemUtil.JAVA_VERSION >= SystemUtil.JAVA_VERSION_25;
// private static final Class<?> THREAD_CLASS = Thread.class;
private static final Class<?> RUNNABLE_CLASS = Runnable.class;
private static Class<?> threadBuilderClass;
Expand Down Expand Up @@ -220,7 +221,7 @@ public static boolean isInNativeMethod(Thread thread, boolean defaultValue) {
}

public static Thread getThread(Runnable task) {
return getThread(task, ALLOW_FUTURE_THREADS);
return getThread(task, ALLOW_VIRTUAL_THREADS);

}

Expand All @@ -243,7 +244,7 @@ public static Thread getThread(Runnable task, boolean allowVirtual) {
}

public static ExecutorService createExecutorService(int maxThreads) {
return createExecutorService(maxThreads, ALLOW_FUTURE_THREADS);
return createExecutorService(maxThreads, ALLOW_VIRTUAL_THREADS);
}

public static ExecutorService createExecutorService(int maxThreads, boolean allowVirtual) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import lucee.runtime.db.DatasourceConnection;
import lucee.runtime.db.DatasourceManagerImpl;
import lucee.runtime.exp.PageException;
import lucee.runtime.thread.ThreadUtil;

public final class StatmentClose implements CloserJob {

Expand All @@ -29,8 +30,7 @@ public String getLablel() {

@Override
public void execute() throws PageException {
// TODO add virtual threads
new Thread(() -> {
ThreadUtil.getThread(() -> {
try {
DBUtil.closeEL(stat);
manager.releaseConnection(null, dc);
Expand Down