Which two demonstrate the valid usage of the keyword synchronized?
A.
interface ThreadSafe {
synchronized void doIt();
}
B.
abstract class ThreadSafe {
synchronized abstract void doIt();
}
C.
class ThreadSafe {
synchronized static void soIt () {}
}
D.
enum ThreadSafe {
ONE, TWO, Three;
synchronized final void doIt () {}
}
Explanation:
The Java programming language provides two basic synchronization idioms:
synchronized methods and synchronized statements.
To make a method synchronized, simply add the synchronized keyword to its declaration.
The answer is C D.
Abstract methods cannot be synchronized.
+1
+1
only C
ikizler burcu
http://www.XquielQMVW.com/XquielQMVW
c,d