Information on threads
Runtime.getRuntime().availableProcessors();
- Cached thread pool
These are used for IO intensive operationsRunnable job = () -> { try{ Thread.sleep(20); }catch(InterruptedException e){ System.println(e.printStackTrace()); } Sysem.out.println(Thread.currentThread().getName()); } ExecutorService executor = Executors.newCachedThreadPool(); // creating cached threadpool for(int i=0; i<10; i++){ executor.execute(job); // executing the job with cached threadpool }