Created
March 7, 2015 17:49
-
-
Save AntonyKapustin/a844069fd2e943d9568e to your computer and use it in GitHub Desktop.
LongSynchronizedSummaryStatistics. Concurrent Long stats.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.LongSummaryStatistics; | |
/** | |
* | |
* @author Anton Kapustin antonkapystin@hotmail.com | |
*/ | |
public class LongSynchronizedSummaryStatistics extends LongSummaryStatistics { | |
public LongSynchronizedSummaryStatistics() { | |
super(); | |
} | |
@Override | |
public synchronized void accept(int value) { | |
super.accept(value); | |
} | |
@Override | |
public synchronized void accept(long value) { | |
super.accept(value); | |
} | |
@Override | |
public synchronized void combine(LongSummaryStatistics other) { | |
super.combine(other); | |
} | |
@Override | |
public String toString() { | |
return String.format( | |
"%s{count=%d, sum=%d, min=%d, average=%f, max=%d}", | |
this.getClass().getSimpleName(), | |
getCount(), | |
getSum(), | |
getMin(), | |
getAverage(), | |
getMax()); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment