Created
August 4, 2014 13:02
-
-
Save clebertsuconic/c192aefd7de11009e945 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public Thread newThread(final Runnable command) | |
{ | |
// attach the thread to a group only if there is no security manager: | |
// when sandboxed, the code does not have the RuntimePermission modifyThreadGroup | |
final Thread t = (Thread)AccessController.doPrivileged(new PrivilegedAction<Object>() | |
{ | |
public Object run() | |
{ | |
Thread t; | |
if (System.getSecurityManager() == null) | |
{ | |
t = new Thread(group, command, "Thread-" + threadCount.getAndIncrement() + " (" + group.getName() + ")"); | |
} | |
else | |
{ | |
t = new Thread(command, "Thread-" + threadCount.getAndIncrement()); | |
} | |
return t; | |
} | |
}); | |
AccessController.doPrivileged(new PrivilegedAction<Object>() | |
{ | |
public Object run() | |
{ | |
t.setDaemon(daemon); | |
t.setPriority(threadPriority); | |
return null; | |
} | |
}); | |
try | |
{ | |
AccessController.doPrivileged(new PrivilegedAction<Object>() | |
{ | |
public Object run() | |
{ | |
t.setContextClassLoader(tccl); | |
return null; | |
} | |
}); | |
} | |
catch (java.security.AccessControlException e) | |
{ | |
HornetQUtilLogger.LOGGER.missingPrivsForClassloader(); | |
} | |
return t; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment