「Java」java.lang.Thread.currentThread()を利用する

サンプルコード

package com.arkgame.study;

import java.lang.Thread.State;

public class ThreadDemo {

	public static void main(String[] args) {
		Thread td = Thread.currentThread();
		long id = td.getId();
		String nn = td.getName();

		int priority = td.getPriority();
		State st = td.getState();

		System.out.printf("ID:%d, Name:%s, Priority:%d, State:%s%n", id, nn, priority, st);

	}

}

実行結果
ID:1, Name:main, Priority:5, State:RUNNABLE

Java

Posted by arkgame