まず、ソース
1、財産
民間最終スレッドグループの親、 親スレッドグループオブジェクトの 文字列名、 スレッドグループ名 maxPriority int型、 最も優先度の高い ブールは破壊され、 破壊するかどうかを ブールデーモン、 それがデーモンスレッドであるかどうかを vmAllowSuspensionブール; 仮想マシンが自動的に一時停止される = 0のint nUnstartedThreadsを、 スレッドを開始していません数 のint nthreadsの値、 スレッドの合計数 、スレッドのスレッド[] スレッド配列 のint NGROUPS、 スレッドグループ番号 スレッドグループのグループ[]; スレッドグループ配列
図2に示すように、設定方法
Cコードから呼び出すプライベートスレッドグループ(){// this.name =「システム」。 this.maxPriority = Thread.MAX_PRIORITY。 this.parent = NULL; } パブリックスレッドグループ(文字列名){ この(にThread.currentThread()getThreadGroup()、名前。) } パブリックスレッドグループ(スレッドグループの親、文字列名){ この(checkParentAccess(親)、親、名前); } プライベートスレッドグループ(ボイド未使用、スレッドグループの親、文字列名){ this.name =名。 this.maxPriority = parent.maxPriority。 this.daemon = parent.daemon。 this.vmAllowSuspension = parent.vmAllowSuspension。 this.parent =親。 parent.add(この); }
図3に示すように、一般的な方法
ボイドcheckParentAccess静的(スレッドグループの親の)プライベート{ parent.checkAccess(); 戻り値はnull; } 確認機関 、公共の文字列のgetName決勝(){ リターン名; } 取得したスレッドグループ のThreadGroupの公開最終のgetParent(){ IF(親= nullを!) parent.checkAccess(); 戻り親; } 親スレッドグループ得るために 公衆のINT最終getMaxPriority(){ 戻りMaxPriorityを; } 最も優先度の高い 公共ブール最終isDaemon(){ リターンデーモン; } もしデーモンスレッド isDestroyedブール同期パブリック(){ リターンを破壊し; } 破壊されています 最終のボイドは、setdaemon公開(ブールデーモン){ のcheckAccess(); this.daemon =デーモン; } デーモンスレッド ます。public voidのcheckAccess決勝(){ System.getSecurityManagerのSecurityManagerのセキュリティ=(); IF(!セキュリティ= NULL){ security.checkAccess (この); } } 確認権限