๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ
728x90
๋ฐ˜์‘ํ˜•

ReentrantLock ์˜ˆ์ œ1

[JAVA] ReentrantLock ์ด๋ž€? ๋“ค์–ด๊ฐ€๊ธฐ ์•ž์„œ, ๋™๊ธฐํ™”๋ฅผ ์œ„ํ•˜์—ฌ synchronized ํ‚ค์›Œ๋“œ๋ฅผ ์‚ฌ์šฉํ•˜๋‹ค ๋ณด๋‹ˆ, ํ•ด๋‹น ํ‚ค์›Œ๋“œ ๋ง๊ณ  ๋‹ค๋ฅธ ๊ฒƒ๋“ค์€ ๋ฌด์—‡์ด ์žˆ์„๊นŒ ์ฐพ์•„๋ณด๊ฒŒ ๋˜์—ˆ์Šต๋‹ˆ๋‹ค. ๊ทธ๋Ÿฌ๋‹ค๊ฐ€ ๋ฐœ๊ฒฌํ•œ ๊ฒƒ์ด ReentrantLock์ž…๋‹ˆ๋‹ค. ํ•ด๋‹น ๊ธ€์—์„œ๋Š” ์•„๋ž˜ 3๊ฐ€์ง€ ์งˆ๋ฌธ์œผ๋กœ ๊ตฌ๋ถ„ ์ง€์–ด ์ž‘์„ฑํ•ด ๋ณด๋„๋ก ํ•˜๊ฒ ์Šต๋‹ˆ๋‹ค. ReentrantLock ์ด๋ž€? ReentrantLock ์‚ฌ์šฉํ•˜๋Š” ๋ฐฉ๋ฒ• ๋ฐ ์˜ˆ์‹œ ReentrantLock VS synchronized ์˜ ์ฐจ์ด์ ์€ ๋ฌด์—‡์ด ์žˆ๋‚˜์š”? 1. ReentrantLock ์ด๋ž€? JAVA ์—์„œ ๋™์‹œ์— ์—ฌ๋Ÿฌ ๊ฐœ์˜ ์Šค๋ ˆ๋“œ๊ฐ€ ์ ‘๊ทผํ•˜๋Š” ๊ฒƒ์„ ์ œ์–ดํ•˜๊ธฐ ์œ„ํ•œ ๋™๊ธฐํ™” ๋ฉ”์ปค๋‹ˆ์ฆ˜ ์ค‘ ํ•˜๋‚˜์ž…๋‹ˆ๋‹ค. ์ˆ˜๋™์œผ๋กœ ์ž ๊ธˆ ์˜์—ญ(Lock) ์˜ ์‹œ์ž‘์ ๊ณผ ๋์ ์„ ์„ค์ •ํ•  ์ˆ˜ ์žˆ๋Š” ๊ฐ์ฒด์ž…๋‹ˆ๋‹ค. ์ฆ‰, ์œ ์—ฐํ•œ ๋™๊ธฐํ™”๋ฅผ ์ œ๊ณตํ•ฉ๋‹ˆ๋‹ค. 2. ReentrantL.. 2023. 11. 1.
728x90
๋ฐ˜์‘ํ˜•