Java Thread.checkAccess()
Syntax
Thread.checkAccess() has the following syntax.
public final void checkAccess()
Example
In the following code shows how to use Thread.checkAccess() method.
/*www. j ava 2 s. co m*/
public class Main {
public static void main(String args[]){
new ThreadClass("A");
Thread t = Thread.currentThread();
try {
t.checkAccess();
System.out.println("You have permission to modify");
}
catch(Exception e) {
System.out.println(e);
}
}
}
class ThreadClass implements Runnable {
Thread t;
String str;
ThreadClass(String str) {
this.str = str;
t = new Thread(this);
// this will call run() function
t.start();
}
public void run() {
System.out.println("This is run() function");
}
}