We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 776728c commit f0690d8Copy full SHA for f0690d8
src/main/java/io/concurrency/chapter05/exam01/README.md
@@ -0,0 +1,4 @@
1
+### MultiThreadExample
2
+- sum 변수에 스레드1과 스레드2가 동시에 접근하기 때문에 한 스레드가 작업 중일 때 다른 스레드가 접근하지 않는다는 것을 보장해야 한다 -> 동시성
3
+- 여러 스레드가 lock을 걸지 않은 채 지역 변수에 접근하게 되면 기대하는 결과 값이 나오지 않는다!!
4
+- CPU 멀티 코어를 활용할 수 있기 때문에 병렬성 측면에서 좋지만 동시성과 동기화를 꼭 주의해야 한다
src/main/java/io/concurrency/chapter05/exam01/SingleThreadExample.java
@@ -9,7 +9,7 @@ public static void main(String[] args) {
9
sum += i;
10
try {
11
Thread.sleep(1);
12
- throw new RuntimeException("error");
+ throw new RuntimeException("error"); //싱글 스레드니까 에러 터지면 애플리케이션 종료
13
} catch (InterruptedException e) {
14
e.printStackTrace();
15
}
0 commit comments