Here you can find the source of canCreateNewThread()
public static boolean canCreateNewThread()
//package com.java2s; //License from project: Open Source License import java.util.concurrent.ForkJoinPool; public class Main { private static ForkJoinPool myForkJoinPool = new ForkJoinPool(100); public static boolean canCreateNewThread() { if (Thread.activeCount() < 20000) { try { return true; } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace();/* w w w.j a va2s . co m*/ } } return false; } public static long activeCount() { return myForkJoinPool.getActiveThreadCount(); } }