// 에드센스

저번 포스팅의 마지막처럼 여러개의 쓰레드를 구현하기 위해서

Thread t1 = new Thread(task);

Thread t1 = new Thread(task);

Thread t1 = new Thread(task);

Thread t1 = new Thread(task);

Thread t1 = new Thread(task);

...

 

과 같은 무지성 선언이 좋지 않은 이유가 뭘까?

 

쓰레드 풀을 사용해야하는 이유

1. 프로그램 성능저하를 방지하기 위해

 

매번 발생되는 작업을 병렬처리하기 위해 스레드를 생성/수거하는데 따른 부담은 프로그램 전체적인 퍼포먼스 저하시킨다. 따라서 스레드풀을 만들어 놓는다.

 

 

2. 다수의 사용자 요청을 처리하기 위해

 

서비스적인 측면으로 바라볼 때, 특히 대규모 프로젝트에서 중요하다. 다수의 사용자의 요청을 수용하고, 빠르게 처리하고 대응하기 위해 스레드풀을 사용한다.

 

 

 

 

쓰레드 풀의 단점

1. 한번에 너무 많은 쓰레드를 생성하면 메모리 낭비가 발생한다

 

많은 병렬처리를 예상해서 1억개의 스레드를 만들어 놓았다고 생각해보자. 실제로 100개정도의 요청과 병렬처리를 했다. 그렇다면.. 나머지 스레드들은 아무일도 하지않고 메모리만 차지하는 최악의 경우가 발생될 수 있다.

 

 

2. 노는 스레드가 발생될 수 있다.

 

1번과 비슷하지만 조금 다르다. 

예를 들어 A,B,C 스레드 3개가 있는데, 병렬적으로 일을 처리하는 과정에서 A,B,C 작업완료 소요시간이 다른 경우 스레드 유휴시간 즉, A스레드는 아직 일이 많아서 허덕이고 있는데, B,C는 일을 다하고 A가 열심히 일하는 것을 보고 놀고만 있는 유휴시간이 발생된다. 자바에서는 이를 방지하기 위해 forkJoinPool 을 지원한다. 아래 링크를 통해 알아보자

https://hamait.tistory.com/612

 

쓰레드풀 과 ForkJoinPool

쓰레드 똑똑똑! 누구니? 쓰레드 에요.. 프로그램(프로세스) 안에서 실행 되는 하나의 흐름 단위에요. 내부에서 while 을 돌면 엄청 오랬동안 일을 할 수 도 있답니다. 쓰레드 끼리는 값 (메모리)

hamait.tistory.com

 

 

쓰레드 풀을 사용한 멀티 쓰레드 구현 예제

package Thread_Practice;

import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

public class ThreadPool2 {

	public static void main(String[] args) {
		BlockingQueue<Runnable> bq = new ArrayBlockingQueue<>(1);
		
		/* corePoolSize = 100	(쓰레드 풀이 기본적으로 몇개의 쓰레드를 풀에 가지고 있을지
		 * maximumPoolSize = 100(이 값을 넘어가면 RejectedExecutionException 발생)
		 * keepAliveTime = 10	(idle 쓰레드의 keep alive time)
		 * TimeUnit.SECONDS		(keepAliveTime의 시간 단위)
		 * workQueue = bq		(corePoolSize를  넘어서는 쓰레드들을 큐잉 처리하기 위한 큐 선언)
		 * */
		ThreadPoolExecutor threadPoolExecutor
        		= new ThreadPoolExecutor(100,100,10,TimeUnit.SECONDS, bq);
		
		Runnable task = new Task2();
		for(int i=0;i<100;i++) {
			threadPoolExecutor.execute(task);
		}
		System.out.println("쓰레드 콜 종료"); 
	}

}

class Task2 implements Runnable{
	
	int num = 0;
	@Override
	public void run() {
		for(int i=0;i<10;i++) {
			System.out.println(Thread.currentThread().getName()+", num = "+num++);
		}
	}
}

 

 

ThreadPoolExecutor threadPoolExecutor

= new ThreadPoolExecutor(corePoolSize , maximumPoolSize , keepAliveTime , TimeUnit.SECONDS , workQueue );

 

각각의 인자들은 다음의 의미를 가진다.

 

 * corePoolSize = 100 (쓰레드 풀이 기본적으로 몇개의 쓰레드를 풀에 가지고 있을지
 * maximumPoolSize = 100(이 값을 넘어가면 RejectedExecutionException 발생)
 * keepAliveTime = 10 (idle 쓰레드의 keep alive time)
 * TimeUnit.SECONDS (keepAliveTime의 시간 단위)
 * workQueue = bq (corePoolSize를  넘어서는 쓰레드들을 큐잉 처리하기 위한 큐 선언)

 

즉 위 코드는

 

[기본적으로 100개의 쓰레드를 가지고있으며]

[100개의 쓰레드가 넘어가면 예외가 발생하고]

[keepAliveTime 가 10초이며]

[ArrayBlockingQueue를 사용한 쓰레드 큐잉]

 

을 하는 쓰레드 풀을 선언한 것이다

 

실행결과는 더보기를 누르면 나온다.

 

더보기

pool-1-thread-2, num = 0
pool-1-thread-3, num = 2
pool-1-thread-3, num = 4
pool-1-thread-3, num = 5
pool-1-thread-1, num = 1
pool-1-thread-4, num = 7
pool-1-thread-3, num = 6
pool-1-thread-2, num = 3
pool-1-thread-3, num = 10
pool-1-thread-5, num = 12
pool-1-thread-4, num = 9
pool-1-thread-4, num = 15
pool-1-thread-1, num = 8
pool-1-thread-1, num = 17
pool-1-thread-4, num = 16
pool-1-thread-6, num = 20
pool-1-thread-6, num = 21
pool-1-thread-6, num = 22
pool-1-thread-6, num = 23
pool-1-thread-6, num = 24
pool-1-thread-6, num = 25
pool-1-thread-6, num = 26
pool-1-thread-6, num = 27
pool-1-thread-6, num = 28
pool-1-thread-6, num = 29
pool-1-thread-1, num = 18
pool-1-thread-7, num = 30
pool-1-thread-7, num = 32
pool-1-thread-7, num = 33
pool-1-thread-7, num = 34
pool-1-thread-7, num = 35
pool-1-thread-7, num = 36
pool-1-thread-7, num = 37
pool-1-thread-7, num = 38
pool-1-thread-7, num = 39
pool-1-thread-7, num = 40
pool-1-thread-5, num = 14
pool-1-thread-5, num = 41
pool-1-thread-5, num = 42
pool-1-thread-5, num = 43
pool-1-thread-5, num = 44
pool-1-thread-5, num = 45
pool-1-thread-5, num = 46
pool-1-thread-3, num = 13
pool-1-thread-2, num = 11
pool-1-thread-3, num = 48
pool-1-thread-5, num = 47
pool-1-thread-1, num = 31
pool-1-thread-1, num = 52
pool-1-thread-1, num = 53
pool-1-thread-1, num = 54
pool-1-thread-1, num = 55
pool-1-thread-1, num = 56
pool-1-thread-4, num = 19
pool-1-thread-4, num = 57
pool-1-thread-4, num = 58
pool-1-thread-4, num = 59
pool-1-thread-4, num = 60
pool-1-thread-4, num = 61
pool-1-thread-5, num = 51
pool-1-thread-3, num = 50
pool-1-thread-3, num = 62
pool-1-thread-3, num = 63
pool-1-thread-2, num = 49
pool-1-thread-2, num = 64
pool-1-thread-2, num = 65
pool-1-thread-2, num = 66
pool-1-thread-2, num = 67
pool-1-thread-2, num = 68
pool-1-thread-2, num = 69
pool-1-thread-12, num = 70
pool-1-thread-12, num = 71
pool-1-thread-12, num = 72
pool-1-thread-12, num = 73
pool-1-thread-11, num = 74
pool-1-thread-11, num = 76
pool-1-thread-10, num = 77
pool-1-thread-10, num = 79
pool-1-thread-10, num = 80
pool-1-thread-10, num = 81
pool-1-thread-10, num = 83
pool-1-thread-10, num = 84
pool-1-thread-10, num = 85
pool-1-thread-10, num = 86
pool-1-thread-10, num = 87
pool-1-thread-10, num = 88
pool-1-thread-13, num = 82
pool-1-thread-13, num = 89
pool-1-thread-13, num = 90
pool-1-thread-13, num = 91
pool-1-thread-13, num = 92
pool-1-thread-13, num = 93
pool-1-thread-13, num = 94
pool-1-thread-13, num = 95
pool-1-thread-13, num = 96
pool-1-thread-13, num = 97
pool-1-thread-9, num = 98
pool-1-thread-9, num = 99
pool-1-thread-9, num = 100
pool-1-thread-9, num = 101
pool-1-thread-9, num = 102
pool-1-thread-9, num = 103
pool-1-thread-9, num = 104
pool-1-thread-9, num = 105
pool-1-thread-9, num = 106
pool-1-thread-9, num = 107
pool-1-thread-12, num = 75
pool-1-thread-12, num = 108
pool-1-thread-12, num = 109
pool-1-thread-12, num = 110
pool-1-thread-12, num = 111
pool-1-thread-12, num = 112
pool-1-thread-11, num = 78
pool-1-thread-11, num = 113
pool-1-thread-11, num = 114
pool-1-thread-11, num = 115
pool-1-thread-11, num = 116
pool-1-thread-11, num = 117
pool-1-thread-11, num = 118
pool-1-thread-11, num = 119
pool-1-thread-8, num = 120
pool-1-thread-8, num = 121
pool-1-thread-8, num = 122
pool-1-thread-8, num = 123
pool-1-thread-8, num = 124
pool-1-thread-8, num = 125
pool-1-thread-8, num = 126
pool-1-thread-8, num = 127
pool-1-thread-8, num = 128
pool-1-thread-8, num = 129
pool-1-thread-15, num = 131
pool-1-thread-15, num = 132
pool-1-thread-15, num = 133
pool-1-thread-15, num = 134
pool-1-thread-15, num = 135
pool-1-thread-15, num = 136
pool-1-thread-15, num = 137
pool-1-thread-15, num = 138
pool-1-thread-15, num = 139
pool-1-thread-15, num = 140
pool-1-thread-14, num = 130
pool-1-thread-14, num = 141
pool-1-thread-14, num = 142
pool-1-thread-14, num = 143
pool-1-thread-14, num = 144
pool-1-thread-14, num = 145
pool-1-thread-14, num = 146
pool-1-thread-14, num = 147
pool-1-thread-14, num = 148
pool-1-thread-14, num = 149
pool-1-thread-16, num = 150
pool-1-thread-16, num = 151
pool-1-thread-16, num = 152
pool-1-thread-16, num = 153
pool-1-thread-16, num = 154
pool-1-thread-16, num = 155
pool-1-thread-16, num = 156
pool-1-thread-17, num = 157
pool-1-thread-17, num = 159
pool-1-thread-17, num = 160
pool-1-thread-17, num = 161
pool-1-thread-17, num = 162
pool-1-thread-17, num = 163
pool-1-thread-17, num = 164
pool-1-thread-17, num = 165
pool-1-thread-17, num = 166
pool-1-thread-17, num = 167
pool-1-thread-16, num = 158
pool-1-thread-16, num = 168
pool-1-thread-16, num = 169
pool-1-thread-18, num = 170
pool-1-thread-18, num = 171
pool-1-thread-18, num = 172
pool-1-thread-18, num = 173
pool-1-thread-18, num = 174
pool-1-thread-18, num = 175
pool-1-thread-18, num = 176
pool-1-thread-18, num = 177
pool-1-thread-18, num = 178
pool-1-thread-18, num = 179
pool-1-thread-19, num = 180
pool-1-thread-19, num = 182
pool-1-thread-19, num = 183
pool-1-thread-19, num = 184
pool-1-thread-19, num = 185
pool-1-thread-19, num = 186
pool-1-thread-19, num = 187
pool-1-thread-19, num = 188
pool-1-thread-20, num = 181
pool-1-thread-20, num = 189
pool-1-thread-20, num = 190
pool-1-thread-20, num = 191
pool-1-thread-20, num = 192
pool-1-thread-20, num = 193
pool-1-thread-20, num = 194
pool-1-thread-20, num = 195
pool-1-thread-20, num = 196
pool-1-thread-20, num = 197
pool-1-thread-19, num = 198
pool-1-thread-19, num = 199
pool-1-thread-21, num = 200
pool-1-thread-21, num = 201
pool-1-thread-21, num = 202
pool-1-thread-22, num = 203
pool-1-thread-22, num = 204
pool-1-thread-22, num = 205
pool-1-thread-22, num = 206
pool-1-thread-22, num = 207
pool-1-thread-22, num = 209
pool-1-thread-22, num = 210
pool-1-thread-22, num = 211
pool-1-thread-22, num = 212
pool-1-thread-22, num = 213
pool-1-thread-23, num = 208
pool-1-thread-23, num = 215
pool-1-thread-23, num = 216
pool-1-thread-23, num = 217
pool-1-thread-23, num = 218
pool-1-thread-23, num = 219
pool-1-thread-23, num = 220
pool-1-thread-23, num = 221
pool-1-thread-23, num = 222
pool-1-thread-23, num = 223
pool-1-thread-21, num = 214
pool-1-thread-21, num = 224
pool-1-thread-21, num = 225
pool-1-thread-21, num = 226
pool-1-thread-21, num = 227
pool-1-thread-21, num = 228
pool-1-thread-21, num = 229
pool-1-thread-24, num = 230
pool-1-thread-25, num = 231
pool-1-thread-25, num = 232
pool-1-thread-25, num = 233
pool-1-thread-25, num = 234
pool-1-thread-25, num = 235
pool-1-thread-25, num = 236
pool-1-thread-25, num = 237
pool-1-thread-25, num = 238
pool-1-thread-25, num = 239
pool-1-thread-25, num = 240
pool-1-thread-24, num = 241
pool-1-thread-26, num = 242
pool-1-thread-24, num = 243
pool-1-thread-24, num = 244
pool-1-thread-24, num = 246
pool-1-thread-24, num = 247
pool-1-thread-24, num = 248
pool-1-thread-24, num = 249
pool-1-thread-24, num = 250
pool-1-thread-24, num = 251
pool-1-thread-26, num = 245
pool-1-thread-26, num = 252
pool-1-thread-26, num = 253
pool-1-thread-26, num = 254
pool-1-thread-26, num = 255
pool-1-thread-26, num = 256
pool-1-thread-26, num = 257
pool-1-thread-26, num = 258
pool-1-thread-26, num = 259
pool-1-thread-27, num = 260
pool-1-thread-27, num = 261
pool-1-thread-27, num = 262
pool-1-thread-27, num = 263
pool-1-thread-27, num = 264
pool-1-thread-28, num = 265
pool-1-thread-28, num = 267
pool-1-thread-28, num = 268
pool-1-thread-28, num = 269
pool-1-thread-28, num = 270
pool-1-thread-28, num = 271
pool-1-thread-27, num = 266
pool-1-thread-27, num = 274
pool-1-thread-27, num = 275
pool-1-thread-27, num = 276
pool-1-thread-27, num = 277
pool-1-thread-28, num = 272
pool-1-thread-28, num = 278
pool-1-thread-28, num = 280
pool-1-thread-28, num = 281
pool-1-thread-29, num = 282
pool-1-thread-29, num = 283
pool-1-thread-29, num = 284
pool-1-thread-29, num = 285
pool-1-thread-29, num = 286
pool-1-thread-29, num = 287
pool-1-thread-29, num = 288
pool-1-thread-29, num = 289
pool-1-thread-29, num = 290
pool-1-thread-29, num = 291
pool-1-thread-30, num = 273
pool-1-thread-30, num = 292
pool-1-thread-30, num = 293
pool-1-thread-30, num = 294
pool-1-thread-30, num = 295
pool-1-thread-30, num = 296
pool-1-thread-30, num = 297
pool-1-thread-30, num = 298
pool-1-thread-30, num = 299
pool-1-thread-30, num = 300
pool-1-thread-31, num = 279
pool-1-thread-31, num = 301
pool-1-thread-31, num = 302
pool-1-thread-31, num = 303
pool-1-thread-31, num = 304
pool-1-thread-31, num = 305
pool-1-thread-31, num = 306
pool-1-thread-31, num = 307
pool-1-thread-31, num = 308
pool-1-thread-31, num = 309
pool-1-thread-32, num = 310
pool-1-thread-33, num = 311
pool-1-thread-33, num = 312
pool-1-thread-34, num = 313
pool-1-thread-34, num = 314
pool-1-thread-34, num = 315
pool-1-thread-34, num = 316
pool-1-thread-34, num = 317
pool-1-thread-34, num = 318
pool-1-thread-34, num = 319
pool-1-thread-34, num = 321
pool-1-thread-34, num = 322
pool-1-thread-34, num = 323
pool-1-thread-33, num = 320
pool-1-thread-33, num = 324
pool-1-thread-33, num = 325
pool-1-thread-33, num = 326
pool-1-thread-33, num = 327
pool-1-thread-33, num = 328
pool-1-thread-33, num = 329
pool-1-thread-33, num = 330
pool-1-thread-32, num = 331
pool-1-thread-32, num = 332
pool-1-thread-32, num = 333
pool-1-thread-32, num = 334
pool-1-thread-32, num = 335
pool-1-thread-32, num = 336
pool-1-thread-32, num = 337
pool-1-thread-32, num = 338
pool-1-thread-32, num = 339
pool-1-thread-37, num = 340
pool-1-thread-37, num = 341
pool-1-thread-37, num = 342
pool-1-thread-37, num = 343
pool-1-thread-37, num = 344
pool-1-thread-37, num = 345
pool-1-thread-37, num = 346
pool-1-thread-37, num = 347
pool-1-thread-37, num = 348
pool-1-thread-37, num = 349
pool-1-thread-36, num = 340
pool-1-thread-36, num = 350
pool-1-thread-36, num = 351
pool-1-thread-36, num = 352
pool-1-thread-36, num = 353
pool-1-thread-36, num = 354
pool-1-thread-36, num = 355
pool-1-thread-36, num = 356
pool-1-thread-36, num = 357
pool-1-thread-36, num = 358
pool-1-thread-38, num = 359
pool-1-thread-38, num = 360
pool-1-thread-38, num = 361
pool-1-thread-38, num = 362
pool-1-thread-38, num = 363
pool-1-thread-38, num = 364
pool-1-thread-38, num = 365
pool-1-thread-38, num = 366
pool-1-thread-38, num = 367
pool-1-thread-38, num = 368
pool-1-thread-39, num = 369
pool-1-thread-39, num = 370
pool-1-thread-39, num = 371
pool-1-thread-39, num = 372
pool-1-thread-39, num = 374
pool-1-thread-39, num = 375
pool-1-thread-39, num = 376
pool-1-thread-39, num = 377
pool-1-thread-39, num = 379
pool-1-thread-39, num = 380
pool-1-thread-41, num = 381
pool-1-thread-41, num = 382
pool-1-thread-41, num = 383
pool-1-thread-41, num = 384
pool-1-thread-41, num = 385
pool-1-thread-41, num = 386
pool-1-thread-41, num = 387
pool-1-thread-41, num = 388
pool-1-thread-41, num = 389
pool-1-thread-41, num = 390
pool-1-thread-42, num = 391
pool-1-thread-42, num = 392
pool-1-thread-42, num = 393
pool-1-thread-42, num = 394
pool-1-thread-42, num = 395
pool-1-thread-42, num = 396
pool-1-thread-42, num = 397
pool-1-thread-42, num = 398
pool-1-thread-42, num = 399
pool-1-thread-42, num = 400
pool-1-thread-35, num = 373
pool-1-thread-35, num = 401
pool-1-thread-35, num = 402
pool-1-thread-35, num = 403
pool-1-thread-35, num = 404
pool-1-thread-35, num = 405
pool-1-thread-35, num = 406
pool-1-thread-35, num = 407
pool-1-thread-35, num = 408
pool-1-thread-35, num = 409
pool-1-thread-43, num = 410
pool-1-thread-43, num = 411
pool-1-thread-43, num = 412
pool-1-thread-43, num = 413
pool-1-thread-43, num = 414
pool-1-thread-43, num = 415
pool-1-thread-40, num = 378
pool-1-thread-40, num = 417
pool-1-thread-40, num = 418
pool-1-thread-40, num = 419
pool-1-thread-40, num = 420
pool-1-thread-40, num = 421
pool-1-thread-40, num = 422
pool-1-thread-40, num = 423
pool-1-thread-40, num = 424
pool-1-thread-40, num = 425
pool-1-thread-43, num = 416
pool-1-thread-43, num = 426
pool-1-thread-44, num = 427
pool-1-thread-44, num = 429
pool-1-thread-44, num = 430
pool-1-thread-44, num = 431
pool-1-thread-44, num = 432
pool-1-thread-44, num = 433
pool-1-thread-44, num = 434
pool-1-thread-44, num = 435
pool-1-thread-44, num = 436
pool-1-thread-44, num = 437
pool-1-thread-43, num = 428
pool-1-thread-43, num = 438
pool-1-thread-45, num = 439
pool-1-thread-45, num = 440
pool-1-thread-45, num = 441
pool-1-thread-45, num = 442
pool-1-thread-45, num = 443
pool-1-thread-45, num = 444
pool-1-thread-45, num = 445
pool-1-thread-45, num = 446
pool-1-thread-45, num = 447
pool-1-thread-45, num = 448
pool-1-thread-46, num = 442
pool-1-thread-46, num = 449
pool-1-thread-46, num = 450
pool-1-thread-46, num = 451
pool-1-thread-46, num = 452
pool-1-thread-46, num = 453
pool-1-thread-46, num = 454
pool-1-thread-46, num = 455
pool-1-thread-46, num = 456
pool-1-thread-46, num = 457
pool-1-thread-47, num = 458
pool-1-thread-47, num = 459
pool-1-thread-47, num = 460
pool-1-thread-47, num = 461
pool-1-thread-47, num = 462
pool-1-thread-47, num = 463
pool-1-thread-47, num = 464
pool-1-thread-47, num = 465
pool-1-thread-47, num = 466
pool-1-thread-47, num = 467
pool-1-thread-48, num = 468
pool-1-thread-48, num = 469
pool-1-thread-48, num = 471
pool-1-thread-48, num = 472
pool-1-thread-48, num = 473
pool-1-thread-48, num = 474
pool-1-thread-48, num = 475
pool-1-thread-48, num = 476
pool-1-thread-48, num = 477
pool-1-thread-48, num = 478
pool-1-thread-50, num = 470
pool-1-thread-50, num = 479
pool-1-thread-50, num = 480
pool-1-thread-50, num = 481
pool-1-thread-50, num = 483
pool-1-thread-50, num = 484
pool-1-thread-50, num = 485
pool-1-thread-50, num = 486
pool-1-thread-50, num = 487
pool-1-thread-50, num = 488
pool-1-thread-49, num = 482
pool-1-thread-49, num = 489
pool-1-thread-49, num = 490
pool-1-thread-49, num = 491
pool-1-thread-49, num = 492
pool-1-thread-49, num = 493
pool-1-thread-49, num = 494
pool-1-thread-49, num = 495
pool-1-thread-49, num = 496
pool-1-thread-51, num = 497
pool-1-thread-51, num = 499
pool-1-thread-51, num = 500
pool-1-thread-51, num = 501
pool-1-thread-51, num = 502
pool-1-thread-51, num = 503
pool-1-thread-51, num = 504
pool-1-thread-51, num = 505
pool-1-thread-51, num = 506
pool-1-thread-51, num = 507
pool-1-thread-49, num = 498
pool-1-thread-52, num = 508
pool-1-thread-52, num = 509
pool-1-thread-52, num = 511
pool-1-thread-53, num = 510
pool-1-thread-53, num = 513
pool-1-thread-53, num = 514
pool-1-thread-53, num = 515
pool-1-thread-53, num = 516
pool-1-thread-53, num = 517
pool-1-thread-53, num = 518
pool-1-thread-53, num = 519
pool-1-thread-53, num = 520
pool-1-thread-53, num = 521
pool-1-thread-52, num = 512
pool-1-thread-52, num = 522
pool-1-thread-52, num = 523
pool-1-thread-52, num = 524
pool-1-thread-52, num = 525
pool-1-thread-52, num = 526
pool-1-thread-52, num = 527
pool-1-thread-54, num = 528
pool-1-thread-54, num = 529
pool-1-thread-54, num = 530
pool-1-thread-54, num = 531
pool-1-thread-54, num = 532
pool-1-thread-54, num = 533
pool-1-thread-54, num = 534
pool-1-thread-54, num = 535
pool-1-thread-54, num = 536
pool-1-thread-54, num = 537
pool-1-thread-55, num = 538
pool-1-thread-55, num = 539
pool-1-thread-55, num = 540
pool-1-thread-55, num = 541
pool-1-thread-55, num = 542
pool-1-thread-55, num = 543
pool-1-thread-55, num = 544
pool-1-thread-55, num = 545
pool-1-thread-55, num = 546
pool-1-thread-55, num = 547
pool-1-thread-56, num = 548
pool-1-thread-56, num = 549
pool-1-thread-56, num = 550
pool-1-thread-56, num = 551
pool-1-thread-56, num = 552
pool-1-thread-56, num = 553
pool-1-thread-56, num = 554
pool-1-thread-56, num = 555
pool-1-thread-56, num = 556
pool-1-thread-57, num = 557
pool-1-thread-57, num = 559
pool-1-thread-57, num = 560
pool-1-thread-57, num = 561
pool-1-thread-57, num = 562
pool-1-thread-57, num = 563
pool-1-thread-57, num = 564
pool-1-thread-57, num = 565
pool-1-thread-57, num = 566
pool-1-thread-57, num = 567
pool-1-thread-56, num = 558
pool-1-thread-58, num = 568
pool-1-thread-58, num = 569
pool-1-thread-58, num = 570
pool-1-thread-59, num = 572
pool-1-thread-59, num = 573
pool-1-thread-59, num = 574
pool-1-thread-59, num = 575
pool-1-thread-59, num = 576
pool-1-thread-59, num = 577
pool-1-thread-59, num = 578
pool-1-thread-59, num = 579
pool-1-thread-59, num = 580
pool-1-thread-59, num = 581
pool-1-thread-58, num = 571
pool-1-thread-58, num = 582
pool-1-thread-58, num = 583
pool-1-thread-58, num = 584
pool-1-thread-58, num = 585
pool-1-thread-58, num = 586
pool-1-thread-58, num = 587
pool-1-thread-60, num = 588
pool-1-thread-60, num = 589
pool-1-thread-60, num = 590
pool-1-thread-60, num = 591
pool-1-thread-60, num = 592
pool-1-thread-60, num = 593
pool-1-thread-60, num = 594
pool-1-thread-60, num = 595
pool-1-thread-60, num = 596
pool-1-thread-60, num = 597
pool-1-thread-61, num = 598
pool-1-thread-61, num = 599
pool-1-thread-61, num = 600
pool-1-thread-61, num = 601
pool-1-thread-61, num = 602
pool-1-thread-61, num = 603
pool-1-thread-61, num = 604
pool-1-thread-61, num = 605
pool-1-thread-61, num = 606
pool-1-thread-61, num = 607
pool-1-thread-68, num = 608
pool-1-thread-68, num = 610
pool-1-thread-68, num = 611
pool-1-thread-68, num = 612
pool-1-thread-68, num = 613
pool-1-thread-68, num = 614
pool-1-thread-68, num = 615
pool-1-thread-68, num = 616
pool-1-thread-68, num = 617
pool-1-thread-68, num = 618
pool-1-thread-67, num = 609
pool-1-thread-67, num = 620
pool-1-thread-67, num = 621
pool-1-thread-67, num = 622
pool-1-thread-67, num = 623
pool-1-thread-67, num = 624
pool-1-thread-67, num = 625
pool-1-thread-67, num = 626
pool-1-thread-67, num = 627
pool-1-thread-67, num = 629
pool-1-thread-63, num = 619
pool-1-thread-66, num = 631
pool-1-thread-65, num = 633
pool-1-thread-65, num = 635
pool-1-thread-64, num = 630
pool-1-thread-64, num = 638
pool-1-thread-64, num = 639
pool-1-thread-64, num = 640
pool-1-thread-64, num = 641
pool-1-thread-64, num = 642
pool-1-thread-64, num = 643
pool-1-thread-64, num = 644
pool-1-thread-64, num = 645
pool-1-thread-64, num = 646
pool-1-thread-65, num = 637
pool-1-thread-65, num = 648
pool-1-thread-65, num = 649
pool-1-thread-65, num = 650
pool-1-thread-65, num = 651
pool-1-thread-65, num = 652
pool-1-thread-65, num = 653
pool-1-thread-65, num = 654
pool-1-thread-62, num = 628
pool-1-thread-62, num = 657
pool-1-thread-62, num = 658
pool-1-thread-62, num = 659
pool-1-thread-62, num = 660
pool-1-thread-62, num = 661
pool-1-thread-62, num = 662
pool-1-thread-62, num = 663
pool-1-thread-62, num = 664
pool-1-thread-62, num = 665
pool-1-thread-72, num = 666
pool-1-thread-72, num = 667
pool-1-thread-72, num = 668
pool-1-thread-72, num = 669
pool-1-thread-72, num = 670
pool-1-thread-72, num = 671
pool-1-thread-72, num = 672
pool-1-thread-72, num = 673
pool-1-thread-72, num = 674
pool-1-thread-72, num = 675
pool-1-thread-74, num = 676
pool-1-thread-74, num = 677
pool-1-thread-74, num = 678
pool-1-thread-74, num = 679
pool-1-thread-74, num = 680
pool-1-thread-74, num = 682
pool-1-thread-73, num = 656
pool-1-thread-73, num = 685
pool-1-thread-73, num = 686
pool-1-thread-73, num = 687
pool-1-thread-73, num = 688
pool-1-thread-73, num = 689
pool-1-thread-73, num = 690
pool-1-thread-73, num = 691
pool-1-thread-73, num = 692
pool-1-thread-73, num = 693
pool-1-thread-78, num = 694
pool-1-thread-78, num = 695
pool-1-thread-78, num = 696
pool-1-thread-78, num = 697
pool-1-thread-78, num = 698
pool-1-thread-78, num = 699
pool-1-thread-78, num = 700
pool-1-thread-92, num = 701
pool-1-thread-92, num = 704
pool-1-thread-71, num = 655
pool-1-thread-71, num = 706
pool-1-thread-71, num = 707
pool-1-thread-70, num = 647
pool-1-thread-70, num = 710
pool-1-thread-70, num = 712
pool-1-thread-70, num = 713
pool-1-thread-69, num = 636
pool-1-thread-69, num = 716
pool-1-thread-69, num = 718
pool-1-thread-69, num = 719
pool-1-thread-66, num = 634
쓰레드 콜 종료
pool-1-thread-89, num = 725
pool-1-thread-89, num = 726
pool-1-thread-89, num = 727
pool-1-thread-89, num = 728
pool-1-thread-89, num = 729
pool-1-thread-89, num = 730
pool-1-thread-89, num = 731
pool-1-thread-89, num = 732
pool-1-thread-89, num = 733
pool-1-thread-89, num = 734
pool-1-thread-63, num = 632
pool-1-thread-76, num = 738
pool-1-thread-76, num = 741
pool-1-thread-76, num = 742
pool-1-thread-76, num = 743
pool-1-thread-76, num = 744
pool-1-thread-76, num = 745
pool-1-thread-76, num = 746
pool-1-thread-76, num = 747
pool-1-thread-76, num = 748
pool-1-thread-90, num = 737
pool-1-thread-90, num = 750
pool-1-thread-88, num = 735
pool-1-thread-88, num = 754
pool-1-thread-88, num = 755
pool-1-thread-88, num = 756
pool-1-thread-88, num = 757
pool-1-thread-88, num = 758
pool-1-thread-88, num = 759
pool-1-thread-88, num = 760
pool-1-thread-88, num = 761
pool-1-thread-88, num = 762
pool-1-thread-93, num = 736
pool-1-thread-93, num = 763
pool-1-thread-97, num = 765
pool-1-thread-97, num = 766
pool-1-thread-87, num = 724
pool-1-thread-87, num = 769
pool-1-thread-87, num = 770
pool-1-thread-87, num = 771
pool-1-thread-87, num = 772
pool-1-thread-87, num = 774
pool-1-thread-87, num = 775
pool-1-thread-98, num = 776
pool-1-thread-98, num = 778
pool-1-thread-98, num = 779
pool-1-thread-98, num = 780
pool-1-thread-98, num = 781
pool-1-thread-98, num = 782
pool-1-thread-98, num = 783
pool-1-thread-98, num = 784
pool-1-thread-84, num = 723
pool-1-thread-84, num = 787
pool-1-thread-84, num = 788
pool-1-thread-84, num = 790
pool-1-thread-84, num = 791
pool-1-thread-66, num = 722
pool-1-thread-66, num = 793
pool-1-thread-66, num = 794
pool-1-thread-66, num = 795
pool-1-thread-66, num = 796
pool-1-thread-66, num = 797
pool-1-thread-66, num = 798
pool-1-thread-66, num = 799
pool-1-thread-69, num = 721
pool-1-thread-69, num = 800
pool-1-thread-69, num = 801
pool-1-thread-69, num = 802
pool-1-thread-69, num = 803
pool-1-thread-69, num = 804
pool-1-thread-85, num = 720
pool-1-thread-85, num = 805
pool-1-thread-85, num = 806
pool-1-thread-85, num = 807
pool-1-thread-85, num = 808
pool-1-thread-85, num = 809
pool-1-thread-85, num = 810
pool-1-thread-85, num = 811
pool-1-thread-85, num = 812
pool-1-thread-85, num = 813
pool-1-thread-83, num = 717
pool-1-thread-83, num = 814
pool-1-thread-83, num = 815
pool-1-thread-83, num = 816
pool-1-thread-70, num = 715
pool-1-thread-70, num = 818
pool-1-thread-70, num = 819
pool-1-thread-82, num = 714
pool-1-thread-82, num = 821
pool-1-thread-82, num = 822
pool-1-thread-82, num = 823
pool-1-thread-82, num = 824
pool-1-thread-82, num = 825
pool-1-thread-82, num = 826
pool-1-thread-82, num = 827
pool-1-thread-82, num = 828
pool-1-thread-81, num = 711
pool-1-thread-81, num = 830
pool-1-thread-81, num = 831
pool-1-thread-81, num = 832
pool-1-thread-71, num = 709
pool-1-thread-71, num = 834
pool-1-thread-71, num = 835
pool-1-thread-71, num = 836
pool-1-thread-71, num = 837
pool-1-thread-71, num = 838
pool-1-thread-71, num = 839
pool-1-thread-80, num = 708
pool-1-thread-80, num = 840
pool-1-thread-80, num = 841
pool-1-thread-80, num = 842
pool-1-thread-80, num = 843
pool-1-thread-80, num = 844
pool-1-thread-80, num = 845
pool-1-thread-92, num = 705
pool-1-thread-92, num = 847
pool-1-thread-92, num = 848
pool-1-thread-79, num = 703
pool-1-thread-79, num = 850
pool-1-thread-79, num = 851
pool-1-thread-79, num = 852
pool-1-thread-79, num = 853
pool-1-thread-79, num = 854
pool-1-thread-79, num = 855
pool-1-thread-78, num = 702
pool-1-thread-78, num = 857
pool-1-thread-78, num = 858
pool-1-thread-74, num = 684
pool-1-thread-74, num = 859
pool-1-thread-74, num = 860
pool-1-thread-74, num = 861
pool-1-thread-77, num = 683
pool-1-thread-77, num = 862
pool-1-thread-77, num = 863
pool-1-thread-77, num = 864
pool-1-thread-77, num = 865
pool-1-thread-77, num = 866
pool-1-thread-77, num = 867
pool-1-thread-77, num = 868
pool-1-thread-77, num = 869
pool-1-thread-77, num = 870
pool-1-thread-75, num = 681
pool-1-thread-75, num = 871
pool-1-thread-75, num = 872
pool-1-thread-75, num = 873
pool-1-thread-75, num = 874
pool-1-thread-75, num = 875
pool-1-thread-75, num = 876
pool-1-thread-79, num = 856
pool-1-thread-79, num = 878
pool-1-thread-79, num = 879
pool-1-thread-92, num = 849
pool-1-thread-92, num = 880
pool-1-thread-92, num = 881
pool-1-thread-92, num = 882
pool-1-thread-92, num = 883
pool-1-thread-80, num = 846
pool-1-thread-80, num = 884
pool-1-thread-80, num = 885
pool-1-thread-81, num = 833
pool-1-thread-81, num = 886
pool-1-thread-81, num = 887
pool-1-thread-82, num = 829
pool-1-thread-70, num = 820
pool-1-thread-70, num = 889
pool-1-thread-83, num = 817
pool-1-thread-83, num = 891
pool-1-thread-83, num = 892
pool-1-thread-84, num = 792
pool-1-thread-84, num = 894
pool-1-thread-99, num = 789
pool-1-thread-99, num = 896
pool-1-thread-99, num = 897
pool-1-thread-99, num = 898
pool-1-thread-99, num = 899
pool-1-thread-98, num = 786
pool-1-thread-98, num = 901
pool-1-thread-100, num = 785
pool-1-thread-100, num = 902
pool-1-thread-87, num = 777
pool-1-thread-87, num = 904
pool-1-thread-95, num = 773
pool-1-thread-95, num = 906
pool-1-thread-95, num = 907
pool-1-thread-95, num = 908
pool-1-thread-95, num = 909
pool-1-thread-95, num = 910
pool-1-thread-95, num = 911
pool-1-thread-95, num = 912
pool-1-thread-95, num = 913
pool-1-thread-95, num = 914
pool-1-thread-97, num = 768
pool-1-thread-97, num = 915
pool-1-thread-97, num = 916
pool-1-thread-97, num = 917
pool-1-thread-97, num = 918
pool-1-thread-97, num = 919
pool-1-thread-97, num = 920
pool-1-thread-97, num = 921
pool-1-thread-96, num = 767
pool-1-thread-96, num = 922
pool-1-thread-96, num = 923
pool-1-thread-96, num = 924
pool-1-thread-96, num = 925
pool-1-thread-96, num = 926
pool-1-thread-96, num = 927
pool-1-thread-96, num = 928
pool-1-thread-96, num = 929
pool-1-thread-96, num = 930
pool-1-thread-93, num = 764
pool-1-thread-93, num = 931
pool-1-thread-86, num = 753
pool-1-thread-86, num = 933
pool-1-thread-86, num = 934
pool-1-thread-86, num = 935
pool-1-thread-86, num = 936
pool-1-thread-86, num = 937
pool-1-thread-86, num = 938
pool-1-thread-86, num = 939
pool-1-thread-90, num = 752
pool-1-thread-90, num = 941
pool-1-thread-90, num = 942
pool-1-thread-90, num = 943
pool-1-thread-94, num = 751
pool-1-thread-94, num = 945
pool-1-thread-94, num = 946
pool-1-thread-94, num = 947
pool-1-thread-76, num = 749
pool-1-thread-91, num = 740
pool-1-thread-91, num = 949
pool-1-thread-91, num = 950
pool-1-thread-91, num = 951
pool-1-thread-91, num = 952
pool-1-thread-91, num = 953
pool-1-thread-91, num = 954
pool-1-thread-91, num = 955
pool-1-thread-91, num = 956
pool-1-thread-63, num = 739
pool-1-thread-63, num = 958
pool-1-thread-63, num = 959
pool-1-thread-63, num = 960
pool-1-thread-63, num = 961
pool-1-thread-91, num = 957
pool-1-thread-94, num = 948
pool-1-thread-94, num = 963
pool-1-thread-94, num = 964
pool-1-thread-94, num = 965
pool-1-thread-90, num = 944
pool-1-thread-90, num = 967
pool-1-thread-90, num = 968
pool-1-thread-90, num = 969
pool-1-thread-86, num = 940
pool-1-thread-86, num = 970
pool-1-thread-93, num = 932
pool-1-thread-93, num = 971
pool-1-thread-93, num = 972
pool-1-thread-93, num = 973
pool-1-thread-87, num = 905
pool-1-thread-100, num = 903
pool-1-thread-100, num = 975
pool-1-thread-100, num = 976
pool-1-thread-100, num = 977
pool-1-thread-99, num = 900
pool-1-thread-99, num = 979
pool-1-thread-99, num = 980
pool-1-thread-99, num = 981
pool-1-thread-84, num = 895
pool-1-thread-84, num = 983
pool-1-thread-84, num = 984
pool-1-thread-83, num = 893
pool-1-thread-83, num = 985
pool-1-thread-83, num = 986
pool-1-thread-70, num = 890
pool-1-thread-81, num = 888
pool-1-thread-81, num = 987
pool-1-thread-81, num = 988
pool-1-thread-75, num = 877
pool-1-thread-75, num = 989
pool-1-thread-75, num = 990
pool-1-thread-99, num = 982
pool-1-thread-100, num = 978
pool-1-thread-100, num = 991
pool-1-thread-100, num = 992
pool-1-thread-100, num = 993
pool-1-thread-93, num = 974
pool-1-thread-93, num = 994
pool-1-thread-94, num = 966
pool-1-thread-94, num = 995
pool-1-thread-63, num = 962
pool-1-thread-63, num = 996
pool-1-thread-63, num = 997

이런 결과가 나온다.

 

 

pool-1-thread-1 ~ pool-1-thread-100의 쓰레드가 동작한다.

 

 

num을 1000까지 증가시키기위해 100개의 쓰레드드리이 각각 10번의 연산을 한 모습이다.

이때 맨 마지막의 numdl 997로 끝난것을 보아 num의 값들이 순서대로 증가한것이 아니라는 것을 알 수 있는데 이는  num++ 오퍼레시연이 Thread Safe하지 않음을 의미한다. 이에대한 해결방법은 추후에 공부하도록 해보자!

 

 

다시 위의 코드에서 corePoolSize을 1로 설정하고 실행해보자, 즉 쓰레드풀에 기본적으로 1개의쓰레드를 가지고 시작한다는 의미이다.

 

 

결과는 다음과 같다

 

더보기

pool-1-thread-2, num = 0
pool-1-thread-2, num = 3
pool-1-thread-2, num = 4
pool-1-thread-2, num = 5
pool-1-thread-3, num = 2
pool-1-thread-1, num = 1
pool-1-thread-3, num = 7
pool-1-thread-2, num = 6
pool-1-thread-4, num = 10
pool-1-thread-3, num = 9
pool-1-thread-1, num = 8
pool-1-thread-5, num = 14
pool-1-thread-3, num = 13
pool-1-thread-4, num = 12
pool-1-thread-2, num = 11
pool-1-thread-4, num = 18
pool-1-thread-3, num = 17
pool-1-thread-5, num = 16
pool-1-thread-1, num = 15
pool-1-thread-5, num = 22
pool-1-thread-5, num = 24
pool-1-thread-5, num = 26
pool-1-thread-5, num = 27
pool-1-thread-3, num = 21
pool-1-thread-3, num = 29
pool-1-thread-3, num = 30
pool-1-thread-3, num = 31
pool-1-thread-4, num = 20
pool-1-thread-7, num = 33
pool-1-thread-2, num = 19
pool-1-thread-2, num = 36
pool-1-thread-7, num = 35
pool-1-thread-7, num = 38
pool-1-thread-7, num = 39
pool-1-thread-4, num = 34
pool-1-thread-3, num = 32
pool-1-thread-5, num = 28
pool-1-thread-5, num = 43
pool-1-thread-5, num = 45
pool-1-thread-6, num = 25
pool-1-thread-6, num = 47
pool-1-thread-6, num = 48
pool-1-thread-1, num = 23
pool-1-thread-1, num = 50
pool-1-thread-6, num = 49
pool-1-thread-5, num = 46
pool-1-thread-6, num = 52
pool-1-thread-5, num = 53
pool-1-thread-3, num = 44
pool-1-thread-3, num = 57
pool-1-thread-3, num = 58
pool-1-thread-3, num = 59
pool-1-thread-3, num = 60
pool-1-thread-3, num = 61
pool-1-thread-3, num = 62
pool-1-thread-3, num = 63
pool-1-thread-3, num = 64
pool-1-thread-3, num = 65
pool-1-thread-3, num = 66
pool-1-thread-3, num = 67
pool-1-thread-3, num = 68
pool-1-thread-3, num = 69
pool-1-thread-3, num = 70
pool-1-thread-3, num = 71
pool-1-thread-3, num = 72
pool-1-thread-3, num = 74
pool-1-thread-3, num = 75
pool-1-thread-3, num = 76
pool-1-thread-3, num = 77
pool-1-thread-3, num = 78
pool-1-thread-3, num = 79
pool-1-thread-3, num = 80
pool-1-thread-3, num = 81
pool-1-thread-3, num = 82
pool-1-thread-3, num = 83
pool-1-thread-3, num = 84
pool-1-thread-3, num = 85
pool-1-thread-3, num = 86
pool-1-thread-11, num = 87
pool-1-thread-4, num = 42
pool-1-thread-4, num = 90
pool-1-thread-7, num = 41
pool-1-thread-4, num = 91
pool-1-thread-8, num = 40
pool-1-thread-2, num = 37
pool-1-thread-8, num = 94
pool-1-thread-4, num = 93
pool-1-thread-7, num = 92
pool-1-thread-11, num = 89
pool-1-thread-12, num = 88
pool-1-thread-10, num = 73
pool-1-thread-10, num = 101
pool-1-thread-10, num = 102
pool-1-thread-10, num = 103
pool-1-thread-10, num = 104
pool-1-thread-10, num = 106
pool-1-thread-10, num = 107
pool-1-thread-10, num = 108
pool-1-thread-3, num = 109
pool-1-thread-3, num = 111
pool-1-thread-3, num = 112
pool-1-thread-9, num = 55
pool-1-thread-5, num = 56
pool-1-thread-6, num = 54
pool-1-thread-6, num = 117
pool-1-thread-6, num = 118
pool-1-thread-15, num = 119
pool-1-thread-15, num = 121
pool-1-thread-15, num = 122
pool-1-thread-1, num = 51
pool-1-thread-15, num = 123
pool-1-thread-6, num = 120
pool-1-thread-5, num = 116
pool-1-thread-5, num = 127
pool-1-thread-5, num = 128
pool-1-thread-5, num = 129
pool-1-thread-9, num = 115
pool-1-thread-9, num = 132
pool-1-thread-9, num = 133
pool-1-thread-9, num = 134
pool-1-thread-9, num = 135
pool-1-thread-9, num = 136
pool-1-thread-17, num = 137
pool-1-thread-17, num = 139
pool-1-thread-17, num = 140
pool-1-thread-3, num = 114
pool-1-thread-14, num = 113
pool-1-thread-14, num = 143
pool-1-thread-10, num = 110
pool-1-thread-13, num = 105
pool-1-thread-12, num = 100
pool-1-thread-11, num = 99
pool-1-thread-7, num = 98
pool-1-thread-4, num = 97
pool-1-thread-7, num = 150
pool-1-thread-4, num = 151
pool-1-thread-8, num = 96
pool-1-thread-8, num = 154
pool-1-thread-2, num = 95
pool-1-thread-8, num = 155
pool-1-thread-8, num = 158
pool-1-thread-4, num = 153
pool-1-thread-7, num = 152
pool-1-thread-11, num = 149
pool-1-thread-18, num = 147
pool-1-thread-12, num = 148
pool-1-thread-20, num = 164
pool-1-thread-13, num = 146
pool-1-thread-13, num = 167
pool-1-thread-21, num = 168
pool-1-thread-21, num = 171
pool-1-thread-10, num = 145
pool-1-thread-10, num = 172
pool-1-thread-21, num = 173
pool-1-thread-21, num = 175
pool-1-thread-21, num = 176
pool-1-thread-21, num = 177
pool-1-thread-21, num = 178
pool-1-thread-14, num = 144
pool-1-thread-3, num = 142
pool-1-thread-3, num = 181
pool-1-thread-3, num = 182
pool-1-thread-3, num = 183
pool-1-thread-17, num = 141
pool-1-thread-17, num = 185
pool-1-thread-17, num = 186
pool-1-thread-9, num = 138
pool-1-thread-9, num = 189
pool-1-thread-9, num = 190
pool-1-thread-5, num = 131
pool-1-thread-5, num = 192
pool-1-thread-5, num = 193
pool-1-thread-5, num = 194
pool-1-thread-24, num = 195
pool-1-thread-24, num = 197
pool-1-thread-24, num = 198
pool-1-thread-24, num = 199
pool-1-thread-24, num = 200
pool-1-thread-24, num = 201
pool-1-thread-16, num = 130
pool-1-thread-6, num = 126
pool-1-thread-15, num = 125
pool-1-thread-15, num = 205
pool-1-thread-15, num = 206
pool-1-thread-15, num = 207
pool-1-thread-1, num = 124
pool-1-thread-15, num = 208
pool-1-thread-15, num = 210
pool-1-thread-6, num = 204
pool-1-thread-16, num = 203
pool-1-thread-24, num = 202
pool-1-thread-24, num = 215
pool-1-thread-24, num = 216
pool-1-thread-24, num = 217
pool-1-thread-5, num = 196
pool-1-thread-5, num = 219
pool-1-thread-5, num = 220
pool-1-thread-5, num = 221
pool-1-thread-5, num = 223
pool-1-thread-5, num = 224
pool-1-thread-9, num = 191
pool-1-thread-9, num = 226
pool-1-thread-9, num = 227
pool-1-thread-9, num = 228
pool-1-thread-9, num = 229
pool-1-thread-27, num = 230
pool-1-thread-27, num = 232
pool-1-thread-17, num = 188
pool-1-thread-17, num = 234
pool-1-thread-17, num = 235
pool-1-thread-17, num = 236
pool-1-thread-28, num = 237
pool-1-thread-23, num = 187
pool-1-thread-23, num = 239
pool-1-thread-23, num = 240
pool-1-thread-23, num = 241
pool-1-thread-23, num = 242
pool-1-thread-23, num = 243
pool-1-thread-23, num = 244
pool-1-thread-23, num = 245
pool-1-thread-3, num = 184
pool-1-thread-14, num = 180
pool-1-thread-21, num = 179
pool-1-thread-10, num = 174
pool-1-thread-20, num = 166
pool-1-thread-22, num = 170
pool-1-thread-13, num = 169
pool-1-thread-12, num = 165
pool-1-thread-18, num = 163
pool-1-thread-11, num = 162
pool-1-thread-11, num = 257
pool-1-thread-7, num = 161
pool-1-thread-4, num = 160
pool-1-thread-8, num = 159
pool-1-thread-19, num = 156
pool-1-thread-2, num = 157
pool-1-thread-19, num = 262
pool-1-thread-8, num = 261
pool-1-thread-4, num = 260
pool-1-thread-7, num = 259
pool-1-thread-11, num = 258
pool-1-thread-18, num = 256
pool-1-thread-12, num = 255
pool-1-thread-13, num = 254
pool-1-thread-22, num = 253
pool-1-thread-20, num = 252
pool-1-thread-28, num = 250
pool-1-thread-10, num = 251
pool-1-thread-21, num = 249
pool-1-thread-21, num = 276
pool-1-thread-21, num = 277
pool-1-thread-21, num = 278
pool-1-thread-21, num = 279
pool-1-thread-21, num = 280
pool-1-thread-21, num = 281
pool-1-thread-21, num = 282
pool-1-thread-21, num = 283
pool-1-thread-21, num = 284
pool-1-thread-21, num = 285
pool-1-thread-21, num = 286
pool-1-thread-21, num = 287
pool-1-thread-14, num = 248
pool-1-thread-3, num = 247
pool-1-thread-23, num = 246
pool-1-thread-17, num = 238
pool-1-thread-27, num = 233
pool-1-thread-9, num = 231
pool-1-thread-5, num = 225
pool-1-thread-24, num = 222
pool-1-thread-26, num = 218
pool-1-thread-16, num = 214
pool-1-thread-29, num = 298
pool-1-thread-6, num = 213
pool-1-thread-6, num = 300
pool-1-thread-6, num = 301
pool-1-thread-6, num = 302
pool-1-thread-6, num = 303
pool-1-thread-6, num = 304
pool-1-thread-25, num = 212
pool-1-thread-15, num = 211
pool-1-thread-1, num = 209
pool-1-thread-15, num = 308
pool-1-thread-15, num = 310
pool-1-thread-15, num = 311
pool-1-thread-15, num = 312
pool-1-thread-15, num = 313
pool-1-thread-15, num = 314
pool-1-thread-15, num = 315
pool-1-thread-30, num = 316
pool-1-thread-25, num = 307
pool-1-thread-25, num = 319
pool-1-thread-25, num = 320
pool-1-thread-25, num = 321
pool-1-thread-25, num = 322
pool-1-thread-29, num = 306
pool-1-thread-6, num = 305
pool-1-thread-16, num = 299
pool-1-thread-16, num = 326
pool-1-thread-26, num = 297
pool-1-thread-26, num = 329
pool-1-thread-26, num = 330
pool-1-thread-26, num = 331
pool-1-thread-26, num = 332
pool-1-thread-26, num = 333
pool-1-thread-26, num = 334
pool-1-thread-26, num = 335
pool-1-thread-26, num = 336
pool-1-thread-26, num = 337
pool-1-thread-26, num = 338
pool-1-thread-26, num = 339
pool-1-thread-26, num = 340
pool-1-thread-26, num = 341
pool-1-thread-26, num = 342
pool-1-thread-26, num = 343
pool-1-thread-26, num = 344
pool-1-thread-26, num = 345
pool-1-thread-26, num = 346
pool-1-thread-24, num = 296
pool-1-thread-5, num = 295
pool-1-thread-5, num = 349
pool-1-thread-5, num = 350
pool-1-thread-9, num = 294
pool-1-thread-27, num = 293
pool-1-thread-17, num = 292
pool-1-thread-23, num = 291
pool-1-thread-3, num = 290
pool-1-thread-3, num = 355
pool-1-thread-14, num = 289
pool-1-thread-14, num = 357
pool-1-thread-14, num = 358
pool-1-thread-21, num = 288
pool-1-thread-21, num = 361
pool-1-thread-10, num = 275
pool-1-thread-10, num = 363
pool-1-thread-28, num = 274
pool-1-thread-20, num = 273
pool-1-thread-22, num = 272
pool-1-thread-13, num = 271
pool-1-thread-12, num = 270
pool-1-thread-18, num = 269
pool-1-thread-11, num = 268
pool-1-thread-11, num = 371
pool-1-thread-7, num = 267
pool-1-thread-4, num = 266
pool-1-thread-4, num = 374
pool-1-thread-8, num = 265
pool-1-thread-19, num = 264
pool-1-thread-2, num = 263
pool-1-thread-19, num = 377
pool-1-thread-19, num = 380
pool-1-thread-8, num = 376
pool-1-thread-4, num = 375
pool-1-thread-8, num = 382
pool-1-thread-7, num = 373
pool-1-thread-11, num = 372
pool-1-thread-18, num = 370
pool-1-thread-12, num = 369
pool-1-thread-13, num = 368
pool-1-thread-13, num = 388
pool-1-thread-13, num = 389
pool-1-thread-22, num = 367
pool-1-thread-20, num = 366
pool-1-thread-20, num = 393
pool-1-thread-28, num = 365
pool-1-thread-10, num = 364
pool-1-thread-21, num = 362
pool-1-thread-21, num = 397
pool-1-thread-21, num = 398
pool-1-thread-14, num = 360
pool-1-thread-23, num = 359
pool-1-thread-23, num = 401
pool-1-thread-23, num = 402
pool-1-thread-3, num = 356
pool-1-thread-3, num = 404
pool-1-thread-17, num = 354
pool-1-thread-27, num = 353
pool-1-thread-9, num = 352
pool-1-thread-9, num = 408
pool-1-thread-5, num = 351
pool-1-thread-5, num = 410
pool-1-thread-5, num = 411
pool-1-thread-5, num = 412
pool-1-thread-5, num = 413
pool-1-thread-5, num = 414
pool-1-thread-5, num = 417
pool-1-thread-5, num = 418
pool-1-thread-5, num = 419
pool-1-thread-5, num = 420
pool-1-thread-35, num = 421
pool-1-thread-35, num = 422
pool-1-thread-35, num = 424
pool-1-thread-35, num = 425
pool-1-thread-35, num = 426
pool-1-thread-35, num = 427
pool-1-thread-35, num = 428
pool-1-thread-35, num = 429
pool-1-thread-35, num = 431
pool-1-thread-35, num = 432
pool-1-thread-24, num = 348
pool-1-thread-24, num = 433
pool-1-thread-24, num = 434
pool-1-thread-24, num = 436
pool-1-thread-26, num = 347
pool-1-thread-31, num = 328
pool-1-thread-31, num = 439
pool-1-thread-31, num = 442
pool-1-thread-31, num = 443
pool-1-thread-16, num = 327
pool-1-thread-16, num = 446
pool-1-thread-6, num = 325
pool-1-thread-29, num = 324
pool-1-thread-25, num = 323
pool-1-thread-30, num = 318
pool-1-thread-30, num = 451
pool-1-thread-15, num = 317
pool-1-thread-15, num = 453
pool-1-thread-1, num = 309
pool-1-thread-30, num = 452
pool-1-thread-25, num = 450
pool-1-thread-29, num = 449
pool-1-thread-29, num = 457
pool-1-thread-6, num = 448
pool-1-thread-29, num = 459
pool-1-thread-16, num = 447
pool-1-thread-31, num = 445
pool-1-thread-35, num = 444
pool-1-thread-35, num = 463
pool-1-thread-38, num = 440
pool-1-thread-38, num = 465
pool-1-thread-38, num = 466
pool-1-thread-5, num = 441
pool-1-thread-26, num = 438
pool-1-thread-24, num = 437
pool-1-thread-37, num = 435
pool-1-thread-36, num = 430
pool-1-thread-39, num = 423
pool-1-thread-39, num = 473
pool-1-thread-33, num = 415
pool-1-thread-34, num = 416
pool-1-thread-34, num = 476
pool-1-thread-34, num = 477
pool-1-thread-9, num = 409
pool-1-thread-27, num = 407
pool-1-thread-27, num = 480
pool-1-thread-27, num = 481
pool-1-thread-27, num = 482
pool-1-thread-17, num = 406
pool-1-thread-3, num = 405
pool-1-thread-23, num = 403
pool-1-thread-14, num = 400
pool-1-thread-21, num = 399
pool-1-thread-21, num = 488
pool-1-thread-10, num = 396
pool-1-thread-10, num = 491
pool-1-thread-10, num = 493
pool-1-thread-10, num = 494
pool-1-thread-28, num = 395
pool-1-thread-20, num = 394
pool-1-thread-20, num = 496
pool-1-thread-22, num = 392
pool-1-thread-22, num = 498
pool-1-thread-13, num = 391
pool-1-thread-11, num = 390
pool-1-thread-11, num = 500
pool-1-thread-11, num = 501
pool-1-thread-11, num = 502
pool-1-thread-11, num = 503
pool-1-thread-11, num = 504
pool-1-thread-11, num = 505
pool-1-thread-12, num = 387
pool-1-thread-18, num = 386
pool-1-thread-18, num = 509
pool-1-thread-7, num = 385
pool-1-thread-8, num = 384
pool-1-thread-8, num = 511
pool-1-thread-8, num = 513
pool-1-thread-8, num = 514
pool-1-thread-8, num = 515
pool-1-thread-8, num = 516
pool-1-thread-8, num = 517
pool-1-thread-8, num = 518
pool-1-thread-8, num = 519
pool-1-thread-18, num = 520
pool-1-thread-4, num = 383
pool-1-thread-19, num = 381
pool-1-thread-19, num = 524
pool-1-thread-19, num = 526
pool-1-thread-32, num = 379
pool-1-thread-32, num = 528
pool-1-thread-2, num = 378
pool-1-thread-32, num = 529
pool-1-thread-32, num = 531
pool-1-thread-19, num = 527
pool-1-thread-19, num = 533
pool-1-thread-13, num = 534
pool-1-thread-13, num = 536
pool-1-thread-13, num = 537
pool-1-thread-13, num = 538
pool-1-thread-13, num = 539
pool-1-thread-40, num = 525
pool-1-thread-40, num = 542
pool-1-thread-40, num = 544
pool-1-thread-40, num = 545
pool-1-thread-40, num = 546
pool-1-thread-40, num = 547
pool-1-thread-40, num = 548
pool-1-thread-40, num = 549
pool-1-thread-40, num = 550
pool-1-thread-40, num = 551
pool-1-thread-4, num = 523
pool-1-thread-18, num = 522
pool-1-thread-8, num = 521
pool-1-thread-49, num = 557
pool-1-thread-7, num = 512
pool-1-thread-46, num = 510
pool-1-thread-46, num = 560
pool-1-thread-46, num = 561
pool-1-thread-46, num = 562
pool-1-thread-46, num = 563
pool-1-thread-46, num = 564
pool-1-thread-46, num = 565
pool-1-thread-19, num = 566
pool-1-thread-12, num = 508
pool-1-thread-19, num = 568
pool-1-thread-19, num = 570
pool-1-thread-19, num = 571
pool-1-thread-19, num = 572
pool-1-thread-19, num = 573
pool-1-thread-19, num = 574
pool-1-thread-19, num = 575
pool-1-thread-19, num = 577
pool-1-thread-19, num = 578
pool-1-thread-11, num = 507
pool-1-thread-51, num = 579
pool-1-thread-51, num = 581
pool-1-thread-51, num = 582
pool-1-thread-51, num = 584
pool-1-thread-51, num = 585
pool-1-thread-51, num = 586
pool-1-thread-51, num = 587
pool-1-thread-51, num = 588
pool-1-thread-51, num = 589
pool-1-thread-51, num = 590
pool-1-thread-14, num = 506
pool-1-thread-14, num = 592
pool-1-thread-14, num = 594
pool-1-thread-14, num = 595
pool-1-thread-14, num = 596
pool-1-thread-14, num = 597
pool-1-thread-14, num = 598
pool-1-thread-14, num = 599
pool-1-thread-14, num = 600
pool-1-thread-14, num = 601
pool-1-thread-22, num = 499
pool-1-thread-22, num = 602
pool-1-thread-22, num = 603
pool-1-thread-22, num = 604
pool-1-thread-53, num = 605
pool-1-thread-53, num = 606
pool-1-thread-53, num = 607
pool-1-thread-53, num = 609
pool-1-thread-53, num = 610
pool-1-thread-53, num = 611
pool-1-thread-53, num = 612
pool-1-thread-53, num = 613
pool-1-thread-53, num = 614
pool-1-thread-53, num = 615
pool-1-thread-20, num = 497
pool-1-thread-20, num = 616
pool-1-thread-28, num = 495
pool-1-thread-28, num = 617
pool-1-thread-28, num = 618
pool-1-thread-28, num = 619
pool-1-thread-9, num = 492
pool-1-thread-51, num = 622
pool-1-thread-51, num = 624
pool-1-thread-51, num = 625
pool-1-thread-51, num = 626
pool-1-thread-51, num = 627
pool-1-thread-51, num = 628
pool-1-thread-51, num = 629
pool-1-thread-51, num = 630
pool-1-thread-51, num = 631
pool-1-thread-51, num = 632
pool-1-thread-42, num = 490
pool-1-thread-42, num = 634
pool-1-thread-42, num = 635
pool-1-thread-21, num = 489
pool-1-thread-21, num = 637
pool-1-thread-21, num = 638
pool-1-thread-21, num = 639
pool-1-thread-21, num = 640
pool-1-thread-23, num = 487
pool-1-thread-23, num = 642
pool-1-thread-23, num = 643
pool-1-thread-23, num = 645
pool-1-thread-23, num = 646
pool-1-thread-23, num = 647
pool-1-thread-3, num = 486
pool-1-thread-41, num = 485
pool-1-thread-41, num = 649
pool-1-thread-41, num = 650
pool-1-thread-17, num = 484
pool-1-thread-17, num = 653
pool-1-thread-17, num = 654
pool-1-thread-17, num = 655
pool-1-thread-17, num = 656
pool-1-thread-17, num = 657
pool-1-thread-27, num = 483
pool-1-thread-34, num = 479
pool-1-thread-34, num = 658
pool-1-thread-34, num = 659
pool-1-thread-34, num = 660
pool-1-thread-34, num = 661
pool-1-thread-34, num = 662
pool-1-thread-34, num = 663
pool-1-thread-57, num = 664
pool-1-thread-57, num = 666
pool-1-thread-57, num = 667
pool-1-thread-57, num = 668
pool-1-thread-57, num = 669
pool-1-thread-57, num = 670
pool-1-thread-57, num = 672
pool-1-thread-20, num = 673
쓰레드 콜 종료
pool-1-thread-6, num = 478
pool-1-thread-6, num = 676
pool-1-thread-6, num = 677
pool-1-thread-6, num = 678
pool-1-thread-6, num = 679
pool-1-thread-6, num = 680
pool-1-thread-6, num = 681
pool-1-thread-6, num = 682
pool-1-thread-6, num = 683
pool-1-thread-6, num = 684
pool-1-thread-33, num = 475
pool-1-thread-33, num = 685
pool-1-thread-33, num = 686
pool-1-thread-33, num = 687
pool-1-thread-33, num = 688
pool-1-thread-33, num = 689
pool-1-thread-33, num = 690
pool-1-thread-33, num = 691
pool-1-thread-33, num = 692
pool-1-thread-39, num = 474
pool-1-thread-39, num = 693
pool-1-thread-39, num = 694
pool-1-thread-39, num = 695
pool-1-thread-39, num = 696
pool-1-thread-36, num = 472
pool-1-thread-36, num = 699
pool-1-thread-36, num = 700
pool-1-thread-36, num = 701
pool-1-thread-36, num = 702
pool-1-thread-36, num = 703
pool-1-thread-36, num = 704
pool-1-thread-36, num = 705
pool-1-thread-36, num = 706
pool-1-thread-37, num = 471
pool-1-thread-37, num = 707
pool-1-thread-37, num = 708
pool-1-thread-37, num = 709
pool-1-thread-24, num = 470
pool-1-thread-24, num = 711
pool-1-thread-24, num = 712
pool-1-thread-26, num = 469
pool-1-thread-26, num = 713
pool-1-thread-26, num = 714
pool-1-thread-5, num = 468
pool-1-thread-38, num = 467
pool-1-thread-38, num = 717
pool-1-thread-38, num = 718
pool-1-thread-38, num = 719
pool-1-thread-38, num = 720
pool-1-thread-38, num = 721
pool-1-thread-35, num = 464
pool-1-thread-35, num = 723
pool-1-thread-35, num = 724
pool-1-thread-35, num = 725
pool-1-thread-31, num = 462
pool-1-thread-31, num = 727
pool-1-thread-31, num = 728
pool-1-thread-31, num = 729
pool-1-thread-31, num = 730
pool-1-thread-16, num = 461
pool-1-thread-16, num = 731
pool-1-thread-29, num = 460
pool-1-thread-29, num = 732
pool-1-thread-29, num = 733
pool-1-thread-29, num = 734
pool-1-thread-15, num = 458
pool-1-thread-15, num = 735
pool-1-thread-15, num = 736
pool-1-thread-15, num = 737
pool-1-thread-15, num = 738
pool-1-thread-15, num = 739
pool-1-thread-15, num = 740
pool-1-thread-15, num = 741
pool-1-thread-15, num = 742
pool-1-thread-15, num = 743
pool-1-thread-25, num = 456
pool-1-thread-25, num = 744
pool-1-thread-30, num = 455
pool-1-thread-30, num = 745
pool-1-thread-30, num = 746
pool-1-thread-30, num = 747
pool-1-thread-30, num = 748
pool-1-thread-30, num = 749
pool-1-thread-1, num = 454
pool-1-thread-35, num = 726
pool-1-thread-35, num = 750
pool-1-thread-35, num = 751
pool-1-thread-35, num = 752
pool-1-thread-38, num = 722
pool-1-thread-5, num = 716
pool-1-thread-5, num = 753
pool-1-thread-5, num = 754
pool-1-thread-5, num = 755
pool-1-thread-5, num = 756
pool-1-thread-5, num = 757
pool-1-thread-5, num = 758
pool-1-thread-5, num = 759
pool-1-thread-26, num = 715
pool-1-thread-26, num = 760
pool-1-thread-26, num = 761
pool-1-thread-37, num = 710
pool-1-thread-37, num = 763
pool-1-thread-37, num = 764
pool-1-thread-59, num = 698
pool-1-thread-59, num = 766
pool-1-thread-59, num = 767
pool-1-thread-59, num = 768
pool-1-thread-59, num = 769
pool-1-thread-59, num = 770
pool-1-thread-59, num = 771
pool-1-thread-59, num = 772
pool-1-thread-59, num = 773
pool-1-thread-59, num = 774
pool-1-thread-39, num = 697
pool-1-thread-57, num = 675
pool-1-thread-57, num = 776
pool-1-thread-20, num = 674
pool-1-thread-20, num = 778
pool-1-thread-20, num = 779
pool-1-thread-20, num = 780
pool-1-thread-20, num = 781
pool-1-thread-20, num = 782
pool-1-thread-20, num = 783
pool-1-thread-20, num = 784
pool-1-thread-20, num = 785
pool-1-thread-58, num = 671
pool-1-thread-58, num = 786
pool-1-thread-58, num = 787
pool-1-thread-34, num = 665
pool-1-thread-34, num = 789
pool-1-thread-34, num = 790
pool-1-thread-34, num = 791
pool-1-thread-34, num = 792
pool-1-thread-34, num = 793
pool-1-thread-34, num = 794
pool-1-thread-34, num = 795
pool-1-thread-34, num = 796
pool-1-thread-34, num = 797
pool-1-thread-41, num = 652
pool-1-thread-41, num = 798
pool-1-thread-41, num = 799
pool-1-thread-41, num = 800
pool-1-thread-41, num = 801
pool-1-thread-41, num = 802
pool-1-thread-41, num = 803
pool-1-thread-22, num = 651
pool-1-thread-22, num = 804
pool-1-thread-22, num = 805
pool-1-thread-3, num = 648
pool-1-thread-3, num = 807
pool-1-thread-3, num = 808
pool-1-thread-3, num = 809
pool-1-thread-56, num = 644
pool-1-thread-56, num = 810
pool-1-thread-56, num = 811
pool-1-thread-21, num = 641
pool-1-thread-21, num = 813
pool-1-thread-21, num = 814
pool-1-thread-42, num = 636
pool-1-thread-42, num = 816
pool-1-thread-42, num = 817
pool-1-thread-55, num = 633
pool-1-thread-55, num = 819
pool-1-thread-55, num = 820
pool-1-thread-9, num = 623
pool-1-thread-9, num = 822
pool-1-thread-9, num = 823
pool-1-thread-28, num = 621
pool-1-thread-54, num = 620
pool-1-thread-54, num = 825
pool-1-thread-54, num = 826
pool-1-thread-54, num = 827
pool-1-thread-54, num = 828
pool-1-thread-54, num = 829
pool-1-thread-54, num = 830
pool-1-thread-54, num = 831
pool-1-thread-54, num = 832
pool-1-thread-19, num = 608
pool-1-thread-19, num = 834
pool-1-thread-19, num = 835
pool-1-thread-19, num = 836
pool-1-thread-19, num = 837
pool-1-thread-19, num = 838
pool-1-thread-19, num = 839
pool-1-thread-19, num = 840
pool-1-thread-19, num = 841
pool-1-thread-19, num = 842
pool-1-thread-52, num = 593
pool-1-thread-52, num = 843
pool-1-thread-52, num = 844
pool-1-thread-52, num = 845
pool-1-thread-52, num = 846
pool-1-thread-52, num = 847
pool-1-thread-52, num = 848
pool-1-thread-52, num = 849
pool-1-thread-52, num = 850
pool-1-thread-52, num = 851
pool-1-thread-40, num = 591
pool-1-thread-40, num = 852
pool-1-thread-40, num = 853
pool-1-thread-40, num = 854
pool-1-thread-40, num = 855
pool-1-thread-40, num = 856
pool-1-thread-40, num = 857
pool-1-thread-40, num = 858
pool-1-thread-40, num = 859
pool-1-thread-40, num = 860
pool-1-thread-50, num = 583
pool-1-thread-50, num = 861
pool-1-thread-50, num = 862
pool-1-thread-50, num = 863
pool-1-thread-50, num = 864
pool-1-thread-50, num = 865
pool-1-thread-50, num = 866
pool-1-thread-50, num = 867
pool-1-thread-50, num = 868
pool-1-thread-50, num = 869
pool-1-thread-11, num = 580
pool-1-thread-11, num = 870
pool-1-thread-49, num = 576
pool-1-thread-49, num = 871
pool-1-thread-49, num = 872
pool-1-thread-49, num = 873
pool-1-thread-49, num = 874
pool-1-thread-49, num = 875
pool-1-thread-49, num = 876
pool-1-thread-49, num = 877
pool-1-thread-49, num = 878
pool-1-thread-12, num = 569
pool-1-thread-46, num = 567
pool-1-thread-46, num = 879
pool-1-thread-46, num = 880
pool-1-thread-7, num = 559
pool-1-thread-7, num = 881
pool-1-thread-7, num = 882
pool-1-thread-7, num = 883
pool-1-thread-7, num = 884
pool-1-thread-8, num = 558
pool-1-thread-8, num = 885
pool-1-thread-8, num = 886
pool-1-thread-8, num = 887
pool-1-thread-48, num = 556
pool-1-thread-48, num = 889
pool-1-thread-48, num = 890
pool-1-thread-48, num = 891
pool-1-thread-48, num = 892
pool-1-thread-48, num = 893
pool-1-thread-10, num = 555
pool-1-thread-10, num = 895
pool-1-thread-10, num = 896
pool-1-thread-10, num = 897
pool-1-thread-10, num = 898
pool-1-thread-18, num = 554
pool-1-thread-4, num = 553
pool-1-thread-44, num = 552
pool-1-thread-44, num = 900
pool-1-thread-44, num = 901
pool-1-thread-44, num = 902
pool-1-thread-44, num = 903
pool-1-thread-44, num = 904
pool-1-thread-44, num = 905
pool-1-thread-44, num = 906
pool-1-thread-44, num = 907
pool-1-thread-44, num = 908
pool-1-thread-43, num = 543
pool-1-thread-43, num = 909
pool-1-thread-43, num = 910
pool-1-thread-43, num = 911
pool-1-thread-43, num = 912
pool-1-thread-43, num = 913
pool-1-thread-43, num = 914
pool-1-thread-43, num = 915
pool-1-thread-13, num = 541
pool-1-thread-13, num = 917
pool-1-thread-13, num = 918
pool-1-thread-13, num = 919
pool-1-thread-13, num = 920
pool-1-thread-47, num = 540
pool-1-thread-47, num = 921
pool-1-thread-47, num = 922
pool-1-thread-47, num = 923
pool-1-thread-45, num = 535
pool-1-thread-45, num = 925
pool-1-thread-45, num = 926
pool-1-thread-45, num = 927
pool-1-thread-45, num = 928
pool-1-thread-45, num = 929
pool-1-thread-45, num = 930
pool-1-thread-45, num = 931
pool-1-thread-45, num = 932
pool-1-thread-45, num = 933
pool-1-thread-32, num = 532
pool-1-thread-32, num = 934
pool-1-thread-32, num = 935
pool-1-thread-2, num = 530
pool-1-thread-2, num = 937
pool-1-thread-2, num = 938
pool-1-thread-2, num = 939
pool-1-thread-2, num = 940
pool-1-thread-2, num = 941
pool-1-thread-2, num = 942
pool-1-thread-32, num = 936
pool-1-thread-32, num = 943
pool-1-thread-32, num = 944
pool-1-thread-47, num = 924
pool-1-thread-47, num = 945
pool-1-thread-47, num = 946
pool-1-thread-43, num = 916
pool-1-thread-43, num = 948
pool-1-thread-10, num = 899
pool-1-thread-10, num = 949
pool-1-thread-10, num = 950
pool-1-thread-48, num = 894
pool-1-thread-48, num = 952
pool-1-thread-48, num = 953
pool-1-thread-48, num = 954
pool-1-thread-8, num = 888
pool-1-thread-8, num = 955
pool-1-thread-8, num = 956
pool-1-thread-8, num = 957
pool-1-thread-8, num = 958
pool-1-thread-54, num = 833
pool-1-thread-9, num = 824
pool-1-thread-9, num = 959
pool-1-thread-9, num = 960
pool-1-thread-9, num = 961
pool-1-thread-9, num = 962
pool-1-thread-9, num = 963
pool-1-thread-55, num = 821
pool-1-thread-55, num = 964
pool-1-thread-55, num = 965
pool-1-thread-55, num = 966
pool-1-thread-42, num = 818
pool-1-thread-42, num = 968
pool-1-thread-42, num = 969
pool-1-thread-21, num = 815
pool-1-thread-21, num = 971
pool-1-thread-56, num = 812
pool-1-thread-56, num = 973
pool-1-thread-22, num = 806
pool-1-thread-22, num = 975
pool-1-thread-22, num = 976
pool-1-thread-22, num = 977
pool-1-thread-22, num = 978
pool-1-thread-22, num = 979
pool-1-thread-22, num = 980
pool-1-thread-58, num = 788
pool-1-thread-58, num = 981
pool-1-thread-57, num = 777
pool-1-thread-39, num = 775
pool-1-thread-39, num = 983
pool-1-thread-37, num = 765
pool-1-thread-37, num = 984
pool-1-thread-26, num = 762
pool-1-thread-26, num = 985
pool-1-thread-58, num = 982
pool-1-thread-58, num = 986
pool-1-thread-58, num = 987
pool-1-thread-58, num = 988
pool-1-thread-56, num = 974
pool-1-thread-56, num = 990
pool-1-thread-56, num = 991
pool-1-thread-56, num = 992
pool-1-thread-56, num = 993
pool-1-thread-21, num = 972
pool-1-thread-21, num = 994
pool-1-thread-42, num = 970
pool-1-thread-55, num = 967
pool-1-thread-55, num = 995
pool-1-thread-55, num = 996
pool-1-thread-10, num = 951
pool-1-thread-10, num = 997
pool-1-thread-47, num = 947
pool-1-thread-47, num = 998
pool-1-thread-58, num = 989
pool-1-thread-47, num = 999

 

 

이번 실행에서는 60개의쓰레드가 동작한 모습이다.

 

 

corePoolSize가 100일때는 100개의 쓰레드가 10번식 연산을 하였지만 이번에는 60개의 쓰레드가 N번 실행됐다. N은 10의 배수이다. run()의 포문이 10번만큼 돌기 때문에 10의 배수만큼 동작하는 것 같다.

 

 

각 쓰레드들의 동작 횟수를 세어보면 어떤 쓰레드는 10번, 어떤 쓰레드는 30번 이렇게 다 다르다. 이유는 무엇일까?

 

 

이 경우에서 corePoolSize가 1이므로 1개의 쓰레드로 시작하였다. 이 쓰레드의 연산이 끝나기 전에 새로운 task의 요청이 들어오면 쓰레드풀에선 새로운 쓰레드를 생성한다. 하지만 기존 쓰레드의 연산이 끝난 후에 새 task 요청이 들어오면 기존 쓰레드를 재사용하여 task를 수행하기에 몇번 재사용 됐느냐에 따라 각 쓰레드들의 연산 횟수가 결정되는 것이다.


이렇게 초기 corePoolSize를 1로하면 존재하는 쓰레드를 재사용하는 방식으로 최대한 효율적으로 동작하기에 불필요한 쓰레드가 줄어듬으로써 소모되는 메모리를 줄일 수 있다. 하지만 그렇다고 무조건 1로 하면 새로운 쓰레드의 생성에 드는 비용이 늘어날 것이므로 적절한 값을 찾아야 할 것 같다.

+ Recent posts