List of usage examples for java.lang SecurityManager checkAccess
public void checkAccess(ThreadGroup g)
SecurityException
if the calling thread is not allowed to modify the thread group argument. From source file:Main.java
public static void main(String[] args) { System.setProperty("java.security.policy", "file:/C:/java.policy"); SecurityManager sm = new Main(); System.setSecurityManager(sm); // check if accepting access for thread group is enabled sm.checkAccess(new ThreadGroup("example")); System.out.println("Allowed!"); }
From source file:org.apache.cassandra.concurrent.ContinuationsExecutor.java
/** * If there is a security manager, makes sure caller has permission to shut * down threads in general (see shutdownPerm). If this passes, additionally * makes sure the caller is allowed to interrupt each worker thread. This * might not be true even if first check passed, if the SecurityManager * treats some threads specially.//w w w.j a va2s . c o m */ private void checkShutdownAccess() { SecurityManager security = System.getSecurityManager(); if (security != null) { security.checkPermission(shutdownPerm); final ReentrantLock mainLock = this.mainLock; mainLock.lock(); try { for (Worker w : workers) security.checkAccess(w.thread); } finally { mainLock.unlock(); } } }