threadgroup_Java ThreadGroup類的checkAccess()方法和示例

threadgroup

ThreadGroup類的checkAccess()方法 (ThreadGroup class checkAccess() method)

  • checkAccess() method is available in java.lang package.

    checkAccess()方法在java.lang包中可用。

  • checkAccess() method is used to check whether the currently running thread has permission to update the thread group or not.

    checkAccess()方法用于檢查當前正在運行的線程是否具有更新線程組的權限。

  • checkAccess() method is not a static method so it is not accessible with the class name (i.e. this method is accessible with the class object only).

    checkAccess()方法不是靜態方法,因此無法使用類名進行訪問(即,只能使用類對象訪問此方法)。

  • checkAccess() method is a final method so it is not overridable (i.e. this method is not overridable in child class).

    checkAccess()方法是最終方法,因此它不可重寫(即,該方法在子類中不可重寫)。

  • This method may throw an exception at the time of accessing a thread group.

    訪問線程組時,此方法可能會引發異常。

    SecurityException: In this exception when the current thread is not authorized to access the thread group when the security manager exists.

    SecurityException:在存在安全管理器的情況下,當當前線程無權訪問線程組時,發生此異常。

Syntax:

句法:

    public final void checkAccess();

Parameter(s):

參數:

  • This method does not accept any parameter.

    此方法不接受任何參數。

Return value:

返回值:

The return type of this method is void, it does not return anything.

此方法的返回類型為void ,它不返回任何內容。

Example:

例:

// Java program to demonstrate the example of 
// checkAccess () method of ThreadGroup Class.
import java.lang.*;
class CheckAccess extends Thread {
// Override run() of Thread class
public void run() {
String name = Thread.currentThread().getName();
System.out.println(name + " " + "finish executing");
}
}
public class Main {
public static void main(String[] args) {
CheckAccess ca = new CheckAccess();
try {
// We are creating an object of ThreadGroup class
ThreadGroup tg1 = new ThreadGroup("ThreadGroup 1");
ThreadGroup tg2 = new ThreadGroup("ThreadGroup 2");
// We are creating an object of Thread class and 
// we are assigning the ThreadGroup of both the thread
Thread th1 = new Thread(tg1, ca, "First Thread");
Thread th2 = new Thread(tg2, ca, "Second Thread");
// Calling start() method with Thread class object 
// of Thread class
th1.start();
th2.start();
// Here we are checking access of ThreadGroup
try {
tg1.checkAccess();
System.out.println(tg1.getName() + " " + "has access");
tg2.checkAccess();
System.out.println(tg2.getName() + " " + "has access");
} catch (SecurityException se) {
System.out.println(se.getMessage());
}
th1.join();
th2.join();
} catch (Exception ex) {
System.out.println(ex.getMessage());
}
}
}

Output

輸出量

E:\Programs>javac Main.java
E:\Programs>java Main
ThreadGroup 1 has access
ThreadGroup 2 has access
First Thread finish executing
Second Thread finish executing

翻譯自: https://www.includehelp.com/java/threadgroup-class-checkacess-method-with-example.aspx

threadgroup

本文來自互聯網用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。
如若轉載,請注明出處:http://www.pswp.cn/news/542231.shtml
繁體地址,請注明出處:http://hk.pswp.cn/news/542231.shtml
英文地址,請注明出處:http://en.pswp.cn/news/542231.shtml

如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!

相關文章

qt tab彈出特效_Nuke Studio 12(影視特效合成軟件)中文版分享

Nuke 12是一款功能強大,世界知名的影視后期特效合成軟件。NUKE是一個獲得學院獎(Academy Award)的數碼合成軟件。已經經過10年的歷練,為藝術家們提供了創造具有高質素的相片效果的圖像的方法。NUKE無需專門的硬件平臺,但卻能為藝術家提供組合…

c ++ 鏈表_C ++程序查找兩個單個鏈表的并集

c 鏈表Problem statement: Write a C program to find the union of two single linked lists. 問題陳述:編寫一個C 程序來查找兩個單個鏈表的并集。 Example: 例: Let the first linked list be:5->4->3->6->1->NULLLet the second l…

精華版線段樹模板

哈哈哈&#xff0c;打了一上午。。。#include<iostream> #include<cstdio> #include<cstdlib> #include<cstring> #include<cmath> #include<algorithm> using namespace std; typedef long long ll; ll a[10000010]; ll lazy[1000000]; …

【轉】unity地形插件T4M使用幫助

unity的地形系統在手機游戲中因為效率問題基本無法使用&#xff0c;只能通過T4M這個地形插件來進行優化制作。下面大概講解一下使用流程及方法。 先中U3D里面用自帶的地形系統刷出想要的地形和貼圖。貼圖可以大概刷一下。后面要重新刷。 用導出腳本ExportTerrain.js導出地形為O…

ansys添加力矩_ANSYS軟件中施加扭矩的方法

ANSYS軟件中施加扭矩的方法胡意立&#xff0c;孫明禮&#xff0c;沈燕青&#xff0c;周佳杰&#xff0c;胡林強【摘要】在機械結構的有限元分析中&#xff0c;常會遇到施加扭矩的問題。文中探討了在ANSYS軟件中施加扭矩的一種方法&#xff0c;以在一個六棱柱一端施加扭矩為實例…

Python | 程序從列表中刪除重復的元素

Example: 例&#xff1a; Input:list1: [10, 20, 10, 20, 30, 40, 30, 50]Output:List after removing duplicate elementslist2: [10, 20, 30, 40, 50]Logic: 邏輯&#xff1a; To implement the program is too easy, we have to append elements one by one to another…

Linux的簡介與虛擬機的管理

Linux的簡介&#xff1a; 嚴格的來講&#xff0c;Linux不算是一個操作系統&#xff0c;只是一個Linux系統中的內核&#xff0c;Linux的全稱是GUN/Linux&#xff0c;這才算是一個真正意義上的Linux系統。 Linux是一個多用戶多任務的操作系統&#xff0c;擁有良好的用戶界面&…

python遞歸查找_Python程序使用遞歸查找數字的冪

python遞歸查找Given the base x and the power y and we have to find the x to the power y using recursion in Python. 給定基數x和冪y &#xff0c;我們必須使用Python中的遞歸找到x到冪y 。 By using recursion – We will be multiplying a number (initially with val…

phalapi可以依賴注入么_PHP 依賴注入

通常調用一個類里面的方法需要如何操作&#xff1a;$class new class();$class->fun()依賴注入模式用來減少程序間的耦合依賴注入共有三種模式&#xff1a;setter 方法注入著重說下setter方法注入并結合ArrayAccess/*** Class Di* property People*/class Di implements Ar…

R語言:ggplot2精細化繪圖——以實用商業化圖表繪圖為例(轉)

本文旨在介紹R語言中ggplot2包的一些精細化操作&#xff0c;主要適用于對R畫圖有一定了解&#xff0c;需要更精細化作圖的人&#xff0c;尤其是那些剛從excel轉ggplot2的各位&#xff0c;有比較頻繁的作圖需求的人。不討論那些樣式非常酷炫的圖表&#xff0c;以實用的商業化圖表…

Linux中常用的命令

1.文件建立 touch file&#xff08;文件的名字&#xff09; 注意&#xff1a; touch不但可以建立文件也可以修改文件的時間戳 時間戳分為&#xff1a; atime&#xff1a;文件內容被訪問的時間標識 mtime&#xff1a;文件內容被修改的時間標識 ctime&#xff1a;文件屬性或文件內…

藍橋杯寶藏排序題目算法(冒泡、選擇、插入)

冒泡排序: def bubble_sort(li): # 函數方式for i in range(len(li)-1):exchangeFalsefor j in range(len(li)-i-1):if li[j]>li[j1]:li[j],li[j1]li[j1],li[j]exchangeTrueif not exchange:return 選擇排序: 從左往右找到最小的元素&#xff0c;放在起始位置…

hive分區用2個字段有何限制_[特性]Hive動態分區功能使用

[特性]Hive動態分區功能使用2016-01-31 21:40說明Hive有兩種分區&#xff0c;一種是靜態分區&#xff0c;也就是普通的分區。另一種是動態分區。動態分區在數據導入時&#xff0c;會根據具體的字段值自行決定導入&#xff0c;并創建相應的分區。使用上更為方面。舉例準備工作創…

Linux系統中輸出輸入的管理

1.什么是輸入和輸出 輸入和輸出是計算機系統中的主機與外部進行通信的系統。它由外圍設備和輸入輸出控制系統兩部分組成&#xff0c;我們在shell中鍵入指令&#xff0c;然后送入CPU中運算產生結果&#xff0c;再將結果送到字符設備中顯示。簡單點來說輸入輸出就是通過我們的鍵盤…

find 命令示例_數組find()方法以及JavaScript中的示例

find 命令示例JavaScript find()方法 (JavaScript find() method) find() method is used to get the first element from an array which passes the given test (condition). find()方法用于從通過給定測試(條件)的數組中獲取第一個元素。 Syntax: 句法&#xff1a; array.…

統計Apache或Nginx訪問日志里的獨立IP訪問數量的Shell

1、把IP數量直接輸出顯示&#xff1a; cat access_log_2011_06_26.log |awk ‘{print $1}’|uniq -c|wc -l 2、把IP數量輸出到文本顯示&#xff1a; cat access_log_2011_06_26.log |awk ‘{print $1}’|uniq -c|wc -l > ip.txt 總結&#xff1a;如果單個訪問日志大小超過2G…

ggplot2箱式圖兩兩比較_R繪圖 第四篇:繪制箱圖(ggplot2)

箱線圖通過繪制觀測數據的五數總括&#xff0c;即最小值、下四分位數、中位數、上四分位數以及最大值&#xff0c;描述了變量值的分布情況。箱線圖能夠顯示出離群點(outlier)&#xff0c;離群點也叫做異常值&#xff0c;通過箱線圖能夠很容易識別出數據中的異常值。箱線圖提供了…

Linux系統中用戶的管理

#####用戶管理###### 1在Linux中&#xff0c;有三種用戶&#xff1a; 1 root : 也成為超級用戶&#xff0c;對系統有控制權限&#xff0c;超級用戶可以不受限制的運行任何命令&#xff0c;root 用戶可以看作是系統的管理員。 2 系統用戶&#xff1a; 系統用戶通常為系統功能所必…

c# 命名空間命名規范_C#命名空間能力問題和解答 套裝3

c# 命名空間命名規范1) There are following namespaces are given below, which is correct about "using" statement in C#.NET? In C#.Net, "using" statement is used to import the namespace in our programWe can create a new namespace with the…

shell 查出文件并復制到另一個文件夾

找出所有大于100M的文件并展示出來find / -size 100M -exec ls -lh {} \;找出特定文件內大于200字節的文件并備份到另一個文件夾里去find /opt/test -type f -size 200c -exec cp {} /opt/test/cp/ \;轉載于:https://blog.51cto.com/406647516/1875417