aspose file tools
The moose likes Threads and Synchronization and the fly likes checkAccess() method of Thread Class ! Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » Threads and Synchronization
Reply Bookmark "checkAccess() method of Thread Class !" Watch "checkAccess() method of Thread Class !" New topic
Author

checkAccess() method of Thread Class !

Dharmin Desai
Ranch Hand

Joined: Feb 28, 2002
Posts: 81
Dear Friends,
Please tell me, how checkAccess method (of Java.Lang.Thread class)will work !
It will check Access on which Thread/Variable and For which Thread ?
It is the best, if anybody can give explanation with one small example.
Dharmin


SCJP2 (93%),SCWCD(88%)<br />-------------------------------<br />Never under estimate yr self, just represent yr profile in proper manner.
George Brown
Ranch Hand

Joined: Sep 26, 2000
Posts: 919
Read up on security policies, the SecurityManager class and its checkAccess() method. You should then be able to answer your own question.
And it checks whether the currently running thread can modify the thread that the checkAccess() message is sent to.
[ May 29, 2002: Message edited by: George Brown ]
Dharmin Desai
Ranch Hand

Joined: Feb 28, 2002
Posts: 81
But george the method is void and not returning anything.
How the running thread intimateed (where i hv written this message) that for the called Thread (Thread to which the message goes to)it is eligible ?
Please reply with some example if possible !
Thanks in advanced.
George Brown
Ranch Hand

Joined: Sep 26, 2000
Posts: 919
From the javadoc:
Throws:
SecurityException - if the current thread is not allowed to access this thread.
As you asked, here's a code snippet:
I wouldn't find much use for the checkAccess() method myself though as the Thread methods that need access would call the checkAccess method on the SecurityManager anyway and throw the SecurityException themselves if access is disallowed. For example stop, suspend, resume, setPriority, setName, and setDaemon will all check whether they have access themselves.
[ May 29, 2002: Message edited by: George Brown ]
Dharmin Desai
Ranch Hand

Joined: Feb 28, 2002
Posts: 81
Thats gr8 , Brown thanks!
 
IntelliJ Java IDE
 
subject: checkAccess() method of Thread Class !
 
Threads others viewed
A question about java thread
Thread Intrerupt
SecurityManager with custom thread groups
interrupt
A few questions on wait(), sleep(int) and InterruptedException
MyEclipse, The Clear Choice