virtual-thread
#thread #virtual-thread
๋ฐฐ๊ฒฝ
์ ํ๋ ๋ฉ๋ชจ๋ฆฌ ํ๊ฒฝ์์ ์ฌ์ฉํ ์ ์๋ [[os/thread]] ์ ์๊ฐ ์ ํ๋์ด์์.
๋ํ ํ์ํ ์ค๋ ๋ ์๊ฐ ์ฆ๊ฐํ๋ฉด์, [[context-switching]] ๋น์ฉ๋ ์ฆ๊ฐํจ.
์์ 2๊ฐ์ง ๋ฌธ์ ์ ์ ํด๊ฒฐํ๊ธฐ ์ํด ๋์จ ๊ฐ๋ ์ด [[virtual-thread]].
ํน์ง
[[context-switching]] ๋น์ฉ์ด ์ ๋ ดํ๋ค
์?
platform thread
์์์ ์ฌ๋ฌvirtual thread
๊ฐ ๋ฒ๊ฑธ์๊ฐ๋ฉด์ ์คํ๋๋ ํํ๊ธฐ์กด ๋ฐฉ์๋ณด๋ค ์ ์ ํ๋ ๋ฉ๋ชจ๋ฆฌ ์ฌ์ด์ฆ๊ฐ ์ ๊ณ , ์ปค๋ ์์ญ์ ํธ์ถ์ด ์ ์
๊ตฌ์กฐ

์ค์ผ์ฅด๋ฌ๊ฐ
platform thread
๋ฅผ ๊ด๋ฆฌํ๋ค.platform thread
๋virtual thread
์ ์์ ๋ถ๋ฐฐ๋ฅผ ๊ด๋ฆฌํ๋ค

virtual thread
๋carrierThread
๋ฅผ ๊ฐ์ง๊ณ ์๋ค.carrierThread
๋platform thread
์ด๋ค.carrierThread
๋workQueue
๋ฅผ ๊ฐ์ง๊ณ ์๋ค.
virtual thread
๋scheduler
๋ฅผ ๊ฐ์ง๊ณ ์๋ค.scheduler
๋ForkJoinPool
์ด๋คscheduler
๋carrierThread
์ poll ์ด๋คscheduler
๋virtual thread
์ ์ค์ผ์ฅด๋ง์ ๋ด๋นํ๋ค
virtual thread
๋runConfiguration
์ ๊ฐ์ง๊ณ ์๋ค.runConfiguration
์ ์ค์ ์์ ๋ด์ฉ(runnable
) ์ ๊ฐ์ง๊ณ ์๋ค
์ ๋ฆฌ
virtual thread
๋ ๊ธฐ์กดplatform thread
๋ฅผ ๋์ฒดํ๋ ๊ฒ์ด ๋ชฉ์ ์ด ์๋.platform thread
์ ๊ธฐ๋ค๋ฆผ์ ๋ํ ๊ฐ์ ์ด ๋ชฉ์ .
virtual thread
๋ฅผ ๋์ ํ๋ค๊ณ ํด์, ๋ฌด์กฐ๊ฑด์ ์ผ๋ก ์ฒ๋ฆฌ๋์ด ๋์์ง์ง ์์.๋ฆฌ์กํฐ๋ธ ํ๋ก๊ทธ๋๋ฐ๊ณผ ๋์ผํ๊ฒ '์ฒ๋ฆฌ๋' ์ ์ฆ๊ฐํ์ง๋ง ๋ ๊ฐ๋ ์ฑ์ด ์ข๊ณ , ๊ฐ๋ฐ์ ์นํ์ ์ธ ๋ฐฉ๋ฒ์ด๋ค.
Reference
https://techblog.woowahan.com/15398/
https://tech.kakao.com/2023/12/22/techmeet-virtualthread/
Last updated
Was this helpful?