package com.github.phantomthief.failover.util;

import static java.lang.Thread.MIN_PRIORITY;

import java.util.List;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.ScheduledThreadPoolExecutor;

import com.google.common.util.concurrent.ThreadFactoryBuilder;

/**
 * @author w.vela
 */
public class SharedCheckExecutorHolder {

    private static final int THREAD_COUNT = 10;

    public static ScheduledExecutorService getInstance() {
        return LazyHolder.INSTANCE;
    }

    private static class LazyHolder {

        private static final ScheduledExecutorService INSTANCE = new ScheduledThreadPoolExecutor(
                THREAD_COUNT,
                new ThreadFactoryBuilder().setNameFormat("scheduled-failover-recovery-check-%d")
                        .setPriority(MIN_PRIORITY)
                        .setDaemon(true) // 
                        .build()) {

            public void shutdown() {
                throw new UnsupportedOperationException();
            }

            public List<Runnable> shutdownNow() {
                throw new UnsupportedOperationException();
            }
        };
    }
}

@@ -41,16 +41,55 @@
 .util;%0A%0A
+import static java.lang.String.format;%0A
 import s
@@ -125,16 +125,16 @@
 IORITY;%0A
-
 %0Aimport 
@@ -264,33 +264,19 @@
 or;%0A
-%0A
 import 
-com.google.common
+java
 .uti
@@ -301,23 +301,63 @@
 dFactory
-Builder
+;%0Aimport java.util.concurrent.atomic.AtomicLong
 ;%0A%0A/**%0A 
@@ -774,96 +774,493 @@
 tory
-Builder().setNameFormat(%22scheduled-failover-recovery-check-%25d%22)%0A                        
+() %7B%0A                    private AtomicLong count = new AtomicLong();%0A                    private static final String NAME_PATTERN = %22scheduled-failover-recovery-check-%25d%22;%0A                    @Override%0A                    public Thread newThread(Runnable r) %7B%0A                        String name = format(NAME_PATTERN, count.getAndIncrement());%0A                        Thread thread = new Thread(r, name);%0A                        thread.setDaemon(true);%0A                        thread
 .set
@@ -1281,16 +1281,17 @@
 RIORITY)
+;
 %0A       
@@ -1311,61 +1311,331 @@
     
-.setDaemon(true) // %0A                        .build()
+if (Thread.getDefaultUncaughtExceptionHandler() == null) %7B%0A                            thread.setUncaughtExceptionHandler((t, e) -%3E %7B%0A                                e.printStackTrace();%0A                            %7D);%0A                        %7D%0A                        return thread;%0A                    %7D%0A                %7D
 ) %7B%0A

Remove dependency of guava for SharedCheckExecutorHolder