2011-08-31 57 views

回答

4

当实例化时。

public Thread() { 
    init(null, null, "Thread-" + nextThreadNum(), 0); 
} 

private void init(ThreadGroup g, Runnable target, String name, long stackSize) { 
    ... 
    /* Set thread ID */ 
    tid = nextThreadID(); 
    ... 
} 
0

它在Thread构造函数上初始化。从这里实施

代码片段:

/* Set thread ID */ 
tid = nextThreadID(); 
0

实例创建的时间。

0

从Thread.getId()返回的源代码中创建Thread实例时(即在其构造函数中)初始化,无论此Thread实例何时实际启动。