QUESTION 21자격증/OCJP_ExamC2018. 7. 24. 01:20
Table of Contents
반응형
QUESTION 21Click the Exhibit button.class Computation extends Thread {private int num;private boolean isComplete;private int result;public Computation(int num){ this.num = num; }public synchronized void run() {result = num * 2;isComplete = true;notify();}public synchronized int getResult() {while ( ! isComplete ){try {wait();} catch (InterruptedException e) {}}return result;}public static void main(String[] args) {Computation[] computations = new Computation[4];for (int i = 0; i < computations.length; i++) {computations[i] = new Computation(i);computations[i].start();}for (Computation c : computations) {System.out.println(c.getResult() + " ");}}}What is the result?A. The code will deadlock.B. The code may run with no output.C. An exception is thrown at runtime.D. The code may run with output "0 6".E. The code may run with output "2 0 6 4".F. The code may run with output "0 2 4 6".Solution : F
반응형
'자격증 > OCJP_ExamC' 카테고리의 다른 글
QUESTION 23 (0) | 2018.07.24 |
---|---|
QUESTION 22 (0) | 2018.07.24 |
QUESTION 20 (0) | 2018.07.24 |
QUESTION 19 (0) | 2018.07.24 |
QUESTION 18 (0) | 2018.07.24 |
@IT grow. :: IT grow.
#IT #먹방 #전자기기 #일상
#개발 #일상