Which one demonstrate the valid usage of the keyword synchronized?

Which one demonstrate the valid usage of the keyword synchronized?

Which one demonstrate the valid usage of the keyword synchronized?

A.
abstract class ThreadSafe { synchronized abstract void doIt(); }

B.
class ThreadSafe { synchronized static void soIt () {} }

C.
enum ThreadSafe { ONE, TWO, Three; synchronized final void doIt () {} }

D.
interface ThreadSafe { synchronized void doIt(); }



Leave a Reply 2

Your email address will not be published. Required fields are marked *


duff

duff

Why C
“enum ThreadSafe { ONE, TWO, Three; synchronized final void doIt () {} }”
not Valid?