[THREAD] JAVA執行緒
:::info
:bulb: Before the 1:1 meeting, ask the manager and employee to fill in the answer. You can design questions according to your needs.
:::
:white_check_mark: 何謂執行緒
1. 前言介紹
program 程式: code的集合,尚未load進記憶體,可以被執行多次(有多個process),靜態的程式碼
process 程序: 是被電腦執行的程式實體(instance),包含有code、系統資源(像是memory, file, i/o devices),變成可被執行狀態,例如我們點開應用程式的行為,就是在將program化為process,包含有memory space跟thread(s),可以藉由inter-process communication(IPC) mechanisms相互溝通。
thread 執行緒: 程序的次單位,每個thread有自己的program counter, stack及Local變數,CPU調度級分派的基本單位,包含在程序當中,共享程序當中的資源及memory space,各負責一個功能,可以在單一的執行緒當中,執行多個tasks,也就是說執行緒是一連串的指示,在同一個程式當中,各個執行緒能獨立並行執行tasks. thread溝通方式,可以透過shared memory, synchronization機制(LOCK)或SEMAPHORES(旗號)<!--特定數值的號誌,根據情境做加減,當數值為0時為unsignaled 大於0時為signaled,依情況管理執行緒對資源的操作,不過無法保證進入順序-->或condition變數
yaahsin changed 2 years agoView mode Like Bookmark