单项选择题X 纠错
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 ruin with output “0 2 4 6”.
你可能喜欢
多项选择题
A. The output may be “r1 = 6, r2 = 14”.
B. The output may be “r1 = 5, r2 = 15”.
C. The output may be “r1 = 8, r2 = 12”.
D. The code may run (and complete) with no output.
E. The code may deadlock (without completing) with no output.
F. M IllegalStateException or InterruptedException may be thrown at runtime.
单项选择题
A. Compilation fails.
B. An exception is thrown at runtime.
C. Synchronizing the run() method would make the class thread-safe.
D. The data in variable “x” are protected from concurrent access problems.
E. Declaring the doThings() method as static would make the class thread-safe.
F. Wrapping the statements within doThings() in a synchronized(new Object()) {} block would make the class thread-safe.
多项选择题
A. private synchronized Object o;
B. void go() { synchronized() { /* code here */ } }
C. public synchronized void go() { /* code here */ }
D. private synchronized(this) void go() { /* code here */ }
E. void go() { synchronized(Object.class) { /* code here */ } }
F. void go() { Object o = new Object(); synchronized(o) { /* code here */ } }
多项选择题
A. Move the line 12 print statement into the foo() method.
B. Change line 7 to public synchronized void go() {.
C. Change the variable declaration on line 3 to private volatile int x;.
D. Wrap the code inside the foo() method with a synchronized( this ) block.
E. Wrap the for loop code inside the go() method with a synchronized block synchronized(this) { // for loop code here }.
多项选择题
A. An exception may be thrown at runtime.
B. The code may run with no output, without exiting.
C.The code may rum with output “A B A B C C “, then exit.
D.The code may ruin with output “A A A B C A B C C “, then exit.
E. The code may rum with output “A B C A B C A B C “, then exit.
F.The code may ruin with output “A B C A A B C A B C “, then exit.
多项选择题
A. 0, 2, 4, 4, 6, 8, 10, 6,
B. 0, 2, 4, 6, 8, 10, 2, 4,
C. 0, 2, 4, 6, 8, 10, 12, 14,
D. 0, 0, 2, 2, 4, 4, 6, 6, 8, 8, 10, 10, 12, 12, 14, 14,
E. 0, 2, 4, 6, 8, 10, 12, 14, 0, 2, 4, 6, 8, 10, 12, 14,
多项选择题
A. declare reset() using the synchronized keyword
B. declare getName() using the synchronized keyword
C. declare getCount() using the synchronized keyword
D. declare the constructor using the synchronized keyword
E. declare increment() using the synchronized keyword
单项选择题
A. Compilation fails.
B. Deadlock occurs.
C. StartMain Start1 Error EndMain End1
D. StartMain Start1 EndMain End1 Start2 End2
E. StartMain Start1 Error Start2 EndMain End2 End1
F.StartMain Start1 EndMain End1 Start2 Error End2
单项选择题
A. Compilation fails.
B. An exception is thrown at runtime.
C. The code executes and prints “StartedComplete”.
D. The code executes and prints “StartedComplete0123”.
E. The code executes and prints “Started0l23Complete”.
单项选择题
A. Compilation fails.
B. An exception is thrown at runtime.
C. The code executes normally and prints “sleep”.
D. The code executes normally, but nothing is printed.