Java SecurityManager getThreadGroup()方法与示例
SecurityManager類的getThreadGroup()方法 (SecurityManager Class getThreadGroup() method)
getThreadGroup() method is available in java.lang package.
getThreadGroup()方法在java.lang包中可用。
getThreadGroup() method is used to return the thread group into which to create any new thread during the time this is being called otherwise it returns thread group of the current thread when no new thread created associated with it during the time this is being called.
getThreadGroup()方法用于在被調(diào)用期間返回要在其中創(chuàng)建任何新線程的線程組,否則,當(dāng)在調(diào)用期間沒(méi)有與其相關(guān)的新創(chuàng)建線程時(shí),它將返回當(dāng)前線程的線程組。
getThreadGroup() method is a non-static method, it is accessible with the class object only and if we try to access the method with the class name then we will get an error.
getThreadGroup()方法是一個(gè)非靜態(tài)方法,只能通過(guò)類對(duì)象訪問(wèn),如果嘗試使用類名稱訪問(wèn)該方法,則會(huì)收到錯(cuò)誤消息。
getThreadGroup() method does not throw an exception at the time returning thread group.
getThreadGroup()方法在返回線程組時(shí)不會(huì)引發(fā)異常。
Syntax:
句法:
public ThreadGroup getThreadGroup();Parameter(s):
參數(shù):
It does not accept any parameter.
它不接受任何參數(shù)。
Return value:
返回值:
The return type of this method is ThreadGroup, it returns the thread group into which to instantiate any new thread.
該方法的返回類型為T(mén)hreadGroup ,它返回實(shí)例化任何新線程的線程組。
Example:
例:
// Java program to demonstrate the example // of ThreadGroup getThreadGroup() method of SecurityManager import java.security.*;public class GetThreadGroup {public static void main(String[] args) {// By using setProperty() method is to set the policy property // with security managerSystem.setProperty("java.security.policy", "file:/C:/java.policy");// Instantiating a SecurityManager objectSecurityManager smgr = new SecurityManager();// By using setSecurityManager() method is to set the// security managerSystem.setSecurityManager(smgr);// By using getThreadGroup() method is to retrieve the// Thread GroupThreadGroup tg = smgr.getThreadGroup();// Display tgSystem.out.println("smgr.getThreadGroup() = " + tg);} }Output
輸出量
smgr.getThreadGroup() = java.lang.ThreadGroup[name=main,maxpri=10]翻譯自: https://www.includehelp.com/java/securitymanager-getthreadgroup-method-with-example.aspx
總結(jié)
以上是生活随笔為你收集整理的Java SecurityManager getThreadGroup()方法与示例的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: SpringBoot官方热部署和远程调试
- 下一篇: JavaScript中的If和Else语