File tree 3 files changed +17
-4
lines changed
src/main/java/io/concurrency/chapter01/exam03
3 files changed +17
-4
lines changed Original file line number Diff line number Diff line change 6
6
import java .util .concurrent .ExecutorService ;
7
7
import java .util .concurrent .Executors ;
8
8
import java .util .concurrent .Future ;
9
-
9
+ /*
10
+ * CPU Bound - 영상처리, AI 작업 관련
11
+ *
12
+ * 멀티코어의 병렬성을 이용한다.
13
+ *
14
+ * CPU 수 >= 스레드 개수
15
+ * */
10
16
public class CPUBoundExample {
11
17
public static void main (String [] args ) throws InterruptedException {
12
18
Original file line number Diff line number Diff line change 5
5
import java .nio .file .Path ;
6
6
import java .util .concurrent .ExecutorService ;
7
7
import java .util .concurrent .Executors ;
8
-
8
+ /*
9
+ * IO Bound - DB작업이나 파일 읽는 작업
10
+ *
11
+ * 멀티스레드의 동시성을 이용한다.
12
+ *
13
+ * CPU 수 < 스레드 개수
14
+ * */
9
15
public class IOBoundExample {
10
16
public static void main (String [] args ) {
11
- int numThreads = Runtime .getRuntime ().availableProcessors () / 2 ;
17
+ int numThreads = Runtime .getRuntime ().availableProcessors () * 2 ;
12
18
ExecutorService executorService = Executors .newFixedThreadPool (numThreads );
13
19
14
20
for (int i = 0 ; i < numThreads ; i ++) {
@@ -17,7 +23,7 @@ public static void main(String[] args) {
17
23
18
24
// IO 가 집중 되는 작업
19
25
for (int j = 0 ; j < 5 ; j ++) {
20
- Files .readAllLines (Path .of ("D :\\ lecture \\ Java-Concurrency-Programming \\ Java-Concurrency-Programming \\ src \\ chapter01\\ exam03\\ sample.txt" ));
26
+ Files .readAllLines (Path .of ("C :\\ workspace \\ java-concurrency-study \\ src \\ main \\ java \\ io \\ concurrency \\ chapter01\\ exam03\\ sample.txt" ));
21
27
System .out .println ("스레드: " + Thread .currentThread ().getName () +", " +j ); // IO Bound 일때 ContextSwitching 이 일어난다
22
28
}
23
29
Original file line number Diff line number Diff line change
1
+ why so happywhy so happywhy so happywhy so happywhy so happywhy so happywhy so happywhy so happywhy so happywhy so happywhy so happywhy so happywhy so happywhy so happywhy so happywhy so happywhy so happy
You can’t perform that action at this time.
0 commit comments