個人知乎 基礎四 多執行緒

2021-08-11 06:52:49 字數 694 閱讀 3455

threadlocal:執行緒本地變數,每個執行緒有乙個副本

執行緒安全變數:

atomicinteger=new atomicinteger(0);

blockingqueue

執行緒池:減少執行緒建立銷毀開銷

//單執行緒excutor

executorservice service=excutors.newsinglethreadexecutor();

service.submit(new runnable())

//固定大小執行緒池

executorservice service=excutors.newfixedthreadpool(2);

//當之前的提交執行完之後關閉執行緒池,不在接受新任務

service.shutdown();

//執行緒池內任務是否都結束

service.isterminated();

future:

返回非同步結果,阻塞等待返回值,timeout,獲取執行緒異常

futurefuture=service.submit(new

callable()

});service.shutdown();

trycatch(exception e)

個人知乎 基礎九 爬蟲入門PySpider

安裝 pip install pyspider scheduler 排程器,排程乙個url處理 processor 處理網頁器,並解析出新的urlclass return 參考資料 pyquery css選擇器參考資料 乙個網頁的框架 docurl text header cookies css選擇...

個人知乎 功能二 問題發布

js請求url controller直接返回json串 js得到json返回值後不重新整理頁面直接渲染html html語言成為轉義,只是純文字了 question.setcontent htmlutils.htmlescape question.getcontent 基本概念 所有敏感詞構建成一棵...

C 基礎複習 四 多執行緒

單執行緒和多執行緒的區別 單執行緒 只用主線程處理,如果乙個操作在占用主線程,那麼其他操作則無法執行 多執行緒 除了主線程外,還開啟了子執行緒來執行操作,子執行緒執行操作時,主線程一樣可以執行其他操作,但子 執行緒無法使用主線程的控制項,主線程也沒法知道子執行緒什麼時候執行完成 關閉跨執行緒檢測,讓...