com.softicar.platform.common.core.threading.SynchronizedCounter Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of platform-common Show documentation
Show all versions of platform-common Show documentation
The SoftiCAR Platform is a lightweight, Java-based library to create interactive business web applications.
package com.softicar.platform.common.core.threading;
/**
* An {@link Integer} counter that is thread-safe.
*
* @author Oliver Richers
*/
public class SynchronizedCounter {
private int value = 0;
/**
* Increments this request counter and returns the previous value.
*
* @return the counter value before the increment, starting from zero
*/
public synchronized int increment() {
return value++;
}
}