-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fiber refactorings #4
base: java21
Are you sure you want to change the base?
Conversation
private final ExecutorService highPriorityPool = | ||
Executors.newCachedThreadPool(new HighPriorityThreadFactory()); | ||
Executors.newThreadPerTaskExecutor(new HighPriorityThreadFactory()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hits these JMH benchmarks
@@ -31,9 +31,7 @@ private String getThreadID() { | |||
abstract String getThreadNamePrefix(); | |||
|
|||
public Thread newThread(Runnable runnable) { | |||
Thread thread = new Thread(runnable); | |||
thread.setName(getThreadNamePrefix() + "-" + getThreadID()); | |||
thread.setDaemon(true); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Virtual threads are always daemon threads
@@ -66,11 +64,11 @@ String getThreadNamePrefix() { | |||
|
|||
private boolean isShutdown = false; | |||
private final ExecutorService lowPriorityPool = | |||
Executors.newCachedThreadPool(new LowPriorityThreadFactory()); | |||
Executors.newThreadPerTaskExecutor(new LowPriorityThreadFactory()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The API says newVirtualThreadPerTaskExecutor is equivalent to newThreadPerTaskExecutor with a factory producing virtual threads
@@ -31,9 +31,7 @@ private String getThreadID() { | |||
abstract String getThreadNamePrefix(); | |||
|
|||
public Thread newThread(Runnable runnable) { | |||
Thread thread = new Thread(runnable); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the new Thread(...) call inside the newThread(...) method used by the _PriorityThreadFactory classes
No description provided.