//這裡有的未知的就不貼出來了
private volatile char name;
//執行緒名稱
private int priority;
//執行緒優先順序
private boolean single_step;
//是否單步執行
private boolean stillborn =
false
;//虛擬機器狀態
private runnable target;
//將會被執行目標物件
private threadgroup group;
//當前執行緒組物件,這裡會用到 securitymanger 如
// securitymanager security = system.getsecuritymanager(); security.getthreadgroup();
private classloader contextclassloader;
//上下文類載入器
private
static int threadinitnumber;
//執行緒編號,執行緒編號每次++實現,++不是執行緒安全的,
//private static synchronized int nextthreadnum()
// threadlocal 用於實現執行緒內的資料共享,這裡得單獨講 threadlocal 時候講
threadlocal.threadlocalmap threadlocals =
null
; threadlocal.threadlocalmap inheritablethreadlocals =
null
;private long stacksize;
//執行緒操作時所需堆疊大小
private long tid;
//執行緒id
//執行緒優先順序
public final static int min_priority=1
;public final static int norm_priority=5
;public final static int max_priority=10
;//中斷阻塞
volatile object parkblocker;
private volatile interruptible blocker;
public
static native thread currentthread()
;//當前執行緒
//構造方法中都調 init(...) 我們具體看
public
thread()
//這個方法屬性介紹時候說過了,編號 ++ 執行緒不安全用 synchronized 修飾
private
static synchronized int nextthreadnum()
//init(...) 將安全檢驗的刪掉,便於清晰**
private
void
init
(threadgroup g, runnable target, string name,
long stacksize, accesscontrolcontext acc)
if(g ==
null)}
g.addunstarted()
;//安全檢查
//初始化賦值
this
.group = g;
this
.daemon = parent.
isdaemon()
;this
.priority = parent.
getpriority()
;setpriority
(priority)
;this
.stacksize = stacksize;
tid =
nextthreadid()
;}
public final synchronized void
join
(long millis)
throws interruptedexception
}else
wait
(delay)
; now = system.
currenttimemillis()
- base;}}
}public state getstate()
//其它都是些c/c++寫的方法,看不見就不介紹了。
Vector原始碼解析 jdk1 8
概述 vector實現了list的介面,底層同樣是基於陣列實現的,可以儲存null。功能結構與arraylist的類似,不同的是執行緒安全的。建構函式protected object elementdata protected int capacityincrement public vector ...
ArrayList原始碼分析 JDK1 8
借助工具類arrays,實現陣列複製 elementdata arrays.copyof elementdata,newcapacity 底層呼叫system.arraycopy system.arraycopy original,0,copy,0,math.min original.length,...
HashMap原始碼分析 JDK1 8
陣列 鍊錶 紅黑樹 陣列儲存元素,當有衝突時,就在該陣列位置形成乙個鍊錶,儲存衝突的元素,當鍊表元素個數大於閾值時,鍊錶就轉換為紅黑樹。transient node table transient int size int threshold final float loadfactor 預設初始容...