Advertisement
Guest User

Untitled

a guest
Oct 16th, 2020 (edited)
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.98 KB | None | 0 0
  1. package it.feargames.mythicmobsfixes;
  2.  
  3. import java.util.concurrent.ExecutorService;
  4. import java.util.concurrent.TimeUnit;
  5.  
  6. public class Executors {
  7.  
  8.     private static Executors instance;
  9.  
  10.     private final ExecutorService fileSaveExecutor;
  11.  
  12.     private Executors() {
  13.         fileSaveExecutor = java.util.concurrent.Executors.newFixedThreadPool(10);
  14.     }
  15.  
  16.     public ExecutorService getFileSaveExecutor() {
  17.         return fileSaveExecutor;
  18.     }
  19.  
  20.     public static void shutdown() {
  21.         if (instance == null) {
  22.             return;
  23.         }
  24.         instance.fileSaveExecutor.shutdown();
  25.         try {
  26.             instance.fileSaveExecutor.awaitTermination(15, TimeUnit.SECONDS);
  27.         } catch (InterruptedException e) {
  28.             e.printStackTrace();
  29.         }
  30.         instance = null;
  31.     }
  32.  
  33.     public static Executors getInstance() {
  34.         if (instance == null) {
  35.             instance = new Executors();
  36.         }
  37.         return instance;
  38.     }
  39. }
  40.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement