Skip to content
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

Open
wants to merge 6 commits into
base: java21
Choose a base branch
from
Open

Fiber refactorings #4

wants to merge 6 commits into from

Conversation

bgprudhomme
Copy link
Member

No description provided.

private final ExecutorService highPriorityPool =
Executors.newCachedThreadPool(new HighPriorityThreadFactory());
Executors.newThreadPerTaskExecutor(new HighPriorityThreadFactory());
Copy link
Member Author

@bgprudhomme bgprudhomme Aug 5, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@@ -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);
Copy link
Member Author

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());
Copy link
Member Author

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);
Copy link
Member Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant