當前位置: 首頁>>編程示例 >>用法及示例精選 >>正文


Java ThreadLocalRandom current()用法及代碼示例

Java ThreadLocalRandom 類的 current() 方法返回當前線程的 ThreadLocalRandom。它不需要參數。

用法:

public static ThreadLocalRandom current()

參數:

NA

返回值:

此方法返回當前線程的 ThreadLocalRandom。

示例

import java.util.concurrent.ThreadLocalRandom;

public class ThreadLocalRandomCurrentExample {
    public static void main(String[] args) {
    	
    	// Returns the LocalThreadRandom of Current thread	
    	System.out.println("Current thread's LocalThreadRandom name is:" +ThreadLocalRandom.current());
    }
}

輸出:

Current thread's LocalThreadRandom name is:[email protected]






相關用法


注:本文由純淨天空篩選整理自 Java ThreadLocalRandom current() method。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。