concurrency 3

# Java Concurrency In Practice - Chapter 1

Introduction 1.1 ๊ฐ„๋žตํ•œ ๋™์‹œ์„ฑ์˜ ์—ญ์‚ฌ (A (Very) Brief History of Concurrency) ๋ฆฌ์†Œ์Šค ํ™œ์šฉ (Resource utilizatio) ํ”„๋กœ๊ทธ๋žจ์€ ์ž…๋ ฅ ๋˜๋Š” ์ถœ๋ ฅ๊ณผ ๊ฐ™์€ ์™ธ๋ถ€ ์ž‘์—…์„ ๊ธฐ๋‹ค๋ ค์•ผํ•˜๋ฉฐ ๋Œ€๊ธฐํ•˜๋Š” ๋™์•ˆ ์œ ์šฉํ•œ ์ž‘์—…์„ ์ˆ˜ํ–‰ ํ•  ์ˆ˜ ์—†๋‹ค. ์ด ๋Œ€๊ธฐ ์‹œ๊ฐ„์„ ์‚ฌ์šฉํ•˜์—ฌ ๋‹ค๋ฅธ ํ”„๋กœ๊ทธ๋žจ์„ ์‹คํ–‰ํ•˜๋Š” ๊ฒƒ์ด ๋” ํšจ์œจ์ ์ผ ๊ฒƒ์ด๋‹ค. ๊ณตํ‰ (Fairness) ์—ฌ๋Ÿฌ ์‚ฌ์šฉ์ž ๋ฐ ํ”„๋กœ๊ทธ๋žจ์ด ์‹œ์Šคํ…œ ๋ฆฌ์†Œ์Šค์— ๋Œ€ํ•ด ๋™์ผํ•œ ์†Œ์œ ๊ถŒ์„ ์ฃผ์žฅ ํ•  ์ˆ˜ ์žˆ๋‹ค. ํ•œ ํ”„๋กœ๊ทธ๋žจ์„ ์‹คํ–‰ ํ•œ ๋‹ค์Œ ๊ทธ ํ”„๋กœ๊ทธ๋žจ์ด ์™„์ „ํžˆ ์ข…๋ฃŒ๋œ ํ›„, ๋‹ค๋ฅธ ํ”„๋กœ๊ทธ๋žจ์„ ์‹œ์ž‘ํ•˜๋Š” ๊ฒƒ๋ณด๋‹ค ์„ธ๋ฐ€ํ•œ ์‹œ๊ฐ„ ์Šฌ๋ผ์ด์‹ฑ์„ ํ†ตํ•ด ์ปดํ“จํ„ฐ ์ž์›์„ ๊ณต์œ ํ•˜๋Š” ๊ฒƒ์ด ์ข‹๋‹ค. ํŽธ์˜ (Convenience) ๋‹จ์ผ ํ”„๋กœ๊ทธ๋žจ์ด ๋ชจ๋“  ์ž‘์—…์„ ์ˆ˜ํ–‰ํ•˜๋„๋ก ์ž‘์„ฑํ•˜๋Š” ๊ฒƒ๋ณด๋‹ค..

JAVA/Concurrency 2020.02.03

# Java Concurrency and Multithreading Tutorial - Concurrency vs Parallelism

Concurrency(๋™์‹œ์„ฑ) ๋ฐ Parallelism(๋ณ‘๋ ฌ ์ฒ˜๋ฆฌ)๋ผ๋Š” ์šฉ์–ด๋Š” ์ข…์ข… ๋‹ค์ค‘ ์Šค๋ ˆ๋“œ ํ”„๋กœ๊ทธ๋žจ๊ณผ ๊ด€๋ จํ•˜์—ฌ ์‚ฌ์šฉ๋œ๋‹ค. ๊ทธ๋Ÿฌ๋‚˜ Concurrency๊ณผ Parallelism์€ ์ •ํ™•ํžˆ ๋ฌด์—‡์„ ์˜๋ฏธํ•˜๋ฉฐ, ์ด ๋‘ ์šฉ์–ด๋Š” ์–ด๋–ป๊ฒŒ ๋‹ค๋ฅธ๊ฐ€? Concurrency Concurrency๋Š” ์‘์šฉ ํ”„๋กœ๊ทธ๋žจ์ด ๋‘˜ ์ด์ƒ์˜ ์ž‘์—…์„ ๋™์‹œ์— ์ง„ํ–‰ํ•˜๊ณ  ์žˆ์Œ์„ ์˜๋ฏธํ•œ๋‹ค. ์ปดํ“จํ„ฐ์— CPU๊ฐ€ ํ•˜๋‚˜๋งŒ ์žˆ์œผ๋ฉด ์‘์šฉ ํ”„๋กœ๊ทธ๋žจ์ด ๋™์‹œ์— ๋‘ ๊ฐœ ์ด์ƒ์˜ ์ž‘์—…์„ ์ง„ํ–‰ํ•˜์ง€ ๋ชปํ•  ์ˆ˜ ์žˆ์ง€๋งŒ, ์‘์šฉ ํ”„๋กœ๊ทธ๋žจ ๋‚ด๋ถ€์—์„œ ํ•œ ๋ฒˆ์— ๋‘ ๊ฐœ ์ด์ƒ์˜ ์ž‘์—…์ด ์ฒ˜๋ฆฌ๋˜๊ณ  ์žˆ๋‹ค. ๋Œ€์‹  CPU๋Š” ์ž‘์—…์ด ์™„๋ฃŒ ๋  ๋•Œ๊นŒ์ง€ ๋‹ค๋ฅธ ์ž‘์—…๊ฐ„์— ์ „ํ™˜ํ•œ๋‹ค. ๋‚ด๋ถ€์—์„œ ๋‹จ์ผ ์Šค๋ ˆ๋“œ๋งŒ ์‹คํ–‰ํ•˜๋”๋ผ๋„ ๋™์‹œ ์‘์šฉ ํ”„๋กœ๊ทธ๋žจ์„ ๊ฐ€์งˆ ์ˆ˜ ์žˆ๋‹ค. CPU๊ฐ€ ์ž‘์—…์ด ์™„๋ฃŒ๋  ๋•Œ๊นŒ์ง€ ์ž‘์—…๊ฐ„ ์ „ํ™˜์„ ๋ฐ˜๋ณตํ•˜๋ฉฐ ..

JAVA/Concurrency 2020.01.31

# Java Concurrency and Multithreading Tutorial - Multithreading Benefits

Multithreading Benefits ๋ฉ€ํ‹ฐ ์Šค๋ ˆ๋”ฉ์˜ ๊ฐ€์žฅ ์ค‘์š”ํ•œ ์ด์ ์€ ์•„๋ž˜์™€ ๊ฐ™๋‹ค. Better CPU utilization Simple program design in some situations More responsive programs More fair division of CPU resources between different tasks Better CPU Utilization ๋กœ์ปฌ ํŒŒ์ผ ์‹œ์Šคํ…œ์—์„œ ํŒŒ์ผ์„ ์ฝ๊ณ  ์ฒ˜๋ฆฌํ•˜๋Š” ์‘์šฉ ํ”„๋กœ๊ทธ๋žจ์„ ์ƒ์ƒํ•ด๋ด๋ผ. ๋””์Šคํฌ์—์„œ ํŒŒ์ผ์„ ์ฝ๋Š”๋ฐ 5์ดˆ๊ฐ€ ๊ฑธ๋ฆฌ๊ณ  ์ฒ˜๋ฆฌํ•˜๋Š”๋ฐ 2์ดˆ๊ฐ€ ๊ฑธ๋ฆฐ๋‹ค๊ณ  ํ•  ๋•Œ, ๋‘ ๊ฐœ์˜ ํŒŒ์ผ์„ ์ฝ์œผ๋ฉด ์ด 14์ดˆ๊ฐ€ ์†Œ์š”๋œ๋‹ค. ๋””์Šคํฌ์—์„œ ํŒŒ์ผ์„ ์ฝ์„ ๋•Œ ๋Œ€๋ถ€๋ถ„์˜ CPU ์‹œ๊ฐ„์€ ๋””์Šคํฌ๊ฐ€ ๋ฐ์ดํ„ฐ๋ฅผ ์ฝ์„ ๋•Œ๊นŒ์ง€ ๋Œ€๊ธฐํ•œ๋‹ค. ๊ทธ ์‹œ๊ฐ„ ๋™์•ˆ CPU๋Š” ๊ฑฐ์˜ ..

JAVA/Concurrency 2019.12.31