-
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?
Changes from 2 commits
9981865
f433ad3
83c3b92
178bfde
fc81a6e
e28b9de
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 commentThe reason will be displayed to describe this comment to others. Learn more. Virtual threads are always daemon threads |
||
Thread thread = Thread.ofVirtual().name(getThreadNamePrefix() + "-", Long.parseLong(getThreadID())).unstarted(runnable); | ||
return thread; | ||
} | ||
} | ||
|
@@ -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 commentThe 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 |
||
private final ExecutorService normalPriorityPool = | ||
Executors.newCachedThreadPool(new NormalPriorityThreadFactory()); | ||
Executors.newThreadPerTaskExecutor(new NormalPriorityThreadFactory()); | ||
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 commentThe reason will be displayed to describe this comment to others. Learn more. Hits these JMH benchmarks |
||
|
||
/** | ||
* @return Shared instance. | ||
|
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