public static Snapshot getSnapshot ( ExecutorService service ) { Preconditions . checkNotNull ( service , "service" ) ; if ( service instanceof ThreadPoolExecutor ) { val tpe = ( ThreadPoolExecutor ) service ; return new Snapshot ( tpe . getQueue ( ) . size ( ) , tpe . getActiveCount ( ) , tpe . getPoolSize ( ) ) ; } else if ( service instanceof ForkJoinPool ) { val fjp = ( ForkJoinPool ) service ; return new Snapshot ( fjp . getQueuedSubmissionCount ( ) , fjp . getActiveThreadCount ( ) , fjp . getPoolSize ( ) ) ; } else { return null ; } }
Gets a snapshot of the given ExecutorService .