Skip to content

Commit

Permalink
Update MeteorExecutor.java
Browse files Browse the repository at this point in the history
  • Loading branch information
RacoonDog authored and Wide-Cat committed Aug 12, 2023
1 parent ffb62c4 commit a3e1271
Showing 1 changed file with 9 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,21 @@

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.atomic.AtomicInteger;

public class MeteorExecutor {
public static ExecutorService executor;

@PreInit
public static void init() {
executor = Executors.newSingleThreadExecutor();
AtomicInteger threadNumber = new AtomicInteger(1);

executor = Executors.newCachedThreadPool((task) -> {
Thread thread = new Thread(task);
thread.setDaemon(true);
thread.setName("Meteor-Executor-" + threadNumber.getAndIncrement());
return thread;
});
}

public static void execute(Runnable task) {
Expand Down

0 comments on commit a3e1271

Please sign in to comment.