-
-
Notifications
You must be signed in to change notification settings - Fork 241
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
55 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
...-core/src/main/java/com/fastasyncworldedit/core/util/task/UUIDKeyQueuedThreadFactory.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package com.fastasyncworldedit.core.util.task; | ||
|
||
import javax.annotation.Nonnull; | ||
import javax.annotation.Nullable; | ||
import java.util.concurrent.ThreadFactory; | ||
import java.util.concurrent.atomic.AtomicInteger; | ||
|
||
public class UUIDKeyQueuedThreadFactory implements ThreadFactory { | ||
|
||
private final ThreadGroup group; | ||
private final AtomicInteger threadNumber = new AtomicInteger(1); | ||
private final String namePrefix; | ||
|
||
public UUIDKeyQueuedThreadFactory() { | ||
group = new ThreadGroup("UUIDKeyQueuedThreadGroup"); | ||
namePrefix = "FAWE UUID-key-queued - "; | ||
} | ||
|
||
public Thread newThread(Runnable r) { | ||
Thread t = new UUIDKeyQueuedThread(group, r, namePrefix + threadNumber.getAndIncrement(), 0); | ||
if (t.isDaemon()) { | ||
t.setDaemon(false); | ||
} | ||
if (t.getPriority() != Thread.NORM_PRIORITY) { | ||
t.setPriority(Thread.NORM_PRIORITY); | ||
} | ||
return t; | ||
} | ||
|
||
public static final class UUIDKeyQueuedThread extends Thread { | ||
|
||
public UUIDKeyQueuedThread(@Nullable ThreadGroup group, Runnable task, @Nonnull String name, long stackSize) { | ||
super(group, task, name, stackSize); | ||
} | ||
|
||
} | ||
|
||
} |