V
Vikram
Hi ,
I have a doubt regarding the synchronized keyword. If there is a
public static synchronized method, how will the code behave, as there
is no instance on which the "lock" can be applied.
For example I have a class ImageCounter.java as below
public class ImageCounter{
private static int uploadCount;
public static synchronized void incImagesUploaded(){
uploadCount++;
}
public static synchronized int getImagesUploaded(){
return uploadCount;
}
}
There are multiple threads accessing the class.
I have a doubt regarding the synchronized keyword. If there is a
public static synchronized method, how will the code behave, as there
is no instance on which the "lock" can be applied.
For example I have a class ImageCounter.java as below
public class ImageCounter{
private static int uploadCount;
public static synchronized void incImagesUploaded(){
uploadCount++;
}
public static synchronized int getImagesUploaded(){
return uploadCount;
}
}
There are multiple threads accessing the class.