To which of the following can we apply the synchronized keyword
Options :
a . A top level class
b . A static member variable
c . A static method
d . An instance variable
e . An instance method
I think the answer is c, d, e,
You can apply the „synchronized“ to an instance method
class Blair2 extends
Thread {
public synchronized void run() {
You can apply the „synchronized“ to an instance variable like „t“:
class Blair extends Thread {
public void run() {
Thread t = Thread.currentThread();
synchronized (t) {
Appreciate your oppinion.
Thanks.