jdk--ThreadPoolExecutor2--LinkedBlockingQueue

ThreadPoolExecutor

線程池滿拒絕執行策略,默認abortpolicy,不執行並拋出異常

AbortPolicy默認拒絕策略implements RejectExecutionHandler

實現rejectExecution(){//拋出異常throw new RejectExecutionException("task"..runnable reject from executor)}

 

blockingqueue-->在ThreaPoolExecutor中使用

 

retrantlock鎖在jdk LinkedBlockingQueue內大量使用場景

LinkedBlockingQueue中存取操作隊列元素數據大量使用retrantlock鎖,控制線程安全,AtomicInteger原子類

當put和take存取node元素,put隊列滿或get隊列空,condition await阻塞等待

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章