Java Thread Lock canCreateNewThread()

Here you can find the source of canCreateNewThread()

Description

can Create New Thread

License

Open Source License

Declaration

public static boolean canCreateNewThread() 

Method Source Code

//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();
    }
}

Related

  1. createConcurrentStack()
  2. downgradeWriteLock(final ReadWriteLock lock)
  3. fillReadWriteLocks(List readLocks, List writeLocks, int curSize, int size)
  4. getAllMessages()