I need to use a global counter in my application which increments count for every request made. I am going to put this counter in a separate class something like this:
public class Counter{
private static int count = 0;
public synchronized static update()
{
count += 1;
}
public synchronized static int getCount()
{
return count;
}
}
There exists only one Counter throughout the lifetime of the application. Do I get any benefit by making it a singleton since there is a single one? Does it make more sense to create a single instance instead of having a class with static variables? What would be the benefit