Java Utililty Methods Thread Lock

List of utility methods to do Thread Lock

Description

The list of methods to do Thread Lock are organized into topic(s).

Method

booleancanCreateNewThread()
can Create New Thread
if (Thread.activeCount() < 20000) {
    try {
        return true;
    } catch (Exception e) {
        e.printStackTrace();
return false;
...
QueuecreateConcurrentStack()
create Concurrent Stack
return (Queue<E>) Collections.asLifoQueue(newConcurrentNonBlockingDeque());
voiddowngradeWriteLock(final ReadWriteLock lock)
downgrade Write Lock
acquireReadLock(lock);
releaseWriteLock(lock);
voidfillReadWriteLocks(List readLocks, List writeLocks, int curSize, int size)
fill Read Write Locks
if (curSize < size) {
    for (int i = curSize; i < size; i++) {
        ReentrantReadWriteLock nrwl = new ReentrantReadWriteLock();
        readLocks.add(nrwl.readLock());
        writeLocks.add(nrwl.writeLock());
MapgetAllMessages()
get All Messages
return getLocaleProperties(getLocale());
LockgetGradingReadLock()
get Grading Read Lock
return READ_WRITE_LOCK.readLock();
GsongetInstance()
get Instance
return SERIALIZER;
MapgetLocaleProperties(Locale locale)
Get the messages for a locale.
Set<String> loadedBundles = null;
Map<String, String> props = null;
int loadedBundleCount = 0;
try {
    readLock.lock();
    loadedBundles = loadedResourceBundles.get(locale);
    props = cachedMessages.get(locale);
    loadedBundleCount = resouceBundleBaseNames.size();
...
ReentrantReadWriteLockgetPropLock(String s)
get Prop Lock
assert Thread.holdsLock(LOCK_MONITOR);
if (locks.containsKey(s)) {
    return locks.get(s);
ReentrantReadWriteLock l = new ReentrantReadWriteLock();
locks.put(s, l);
return l;
ClassloadClass(String className)
Loads a class.
ClassLoader ccl = Thread.currentThread().getContextClassLoader();
if (ccl == null) {
    try {
        return loadClass(className, null);
    } catch (ClassNotFoundException cnf) {
        return loadClassWithRegisteredClassLoaders(className);
try {
    return loadClass(className, ccl);
} catch (ClassNotFoundException cnf) {
    try {
        return loadClass(className, null);
    } catch (ClassNotFoundException cnf2) {
        return loadClassWithRegisteredClassLoaders(className);