| 115 | } |
| 116 | |
| 117 | public static void initThreadPool(@NotNull ExecutorService pool, |
| 118 | @NotNull ScheduledExecutorService scheduled) { |
| 119 | taskLock.lock(); |
| 120 | try { |
| 121 | //noinspection ConstantValue |
| 122 | if (pool == null || scheduled == null) |
| 123 | throw new IllegalArgumentException(); |
| 124 | |
| 125 | if (threadPoolDefault != null || threadPoolScheduled != null) |
| 126 | throw new IllegalStateException("ThreadPool Has Inited."); |
| 127 | threadPoolDefault = pool; |
| 128 | threadPoolScheduled = scheduled; |
| 129 | threadPoolCritical = newCriticalThreadPool("ZezeCriticalPool"); |
| 130 | ThreadDiagnosable.startDiagnose(30_000); |
| 131 | } finally { |
| 132 | taskLock.unlock(); |
| 133 | } |
| 134 | } |
| 135 | |
| 136 | public static boolean tryInitThreadPool() { |
| 137 | return tryInitThreadPool(null); |