@@ -14,12 +14,12 @@ public class MapStatsContainer implements StatsContainer {
1414 private final Map <String , LearnerStatistic > statistics = new HashMap <>(); // id -> stat
1515
1616 @ Override
17- public void addTextInfo (String id , @ Nullable String description , String text ) {
17+ public synchronized void addTextInfo (String id , @ Nullable String description , String text ) {
1818 statistics .put (id , new TextStatistic (id , description , text ));
1919 }
2020
2121 @ Override
22- public Optional <String > getTextValue (String id ) {
22+ public synchronized Optional <String > getTextValue (String id ) {
2323 var value = statistics .get (id );
2424 if (value instanceof TextStatistic textStatistic ) {
2525 return Optional .of (textStatistic .getText ());
@@ -28,12 +28,12 @@ public Optional<String> getTextValue(String id) {
2828 }
2929
3030 @ Override
31- public void setFlag (String id , @ Nullable String description , boolean value ) {
31+ public synchronized void setFlag (String id , @ Nullable String description , boolean value ) {
3232 statistics .put (id , new FlagStatistic (id , description , value ));
3333 }
3434
3535 @ Override
36- public Optional <Boolean > getFlagValue (String id ) {
36+ public synchronized Optional <Boolean > getFlagValue (String id ) {
3737 var value = statistics .get (id );
3838 if (value instanceof FlagStatistic flagStatistic ) {
3939 return Optional .of (flagStatistic .isFlagged ());
@@ -42,7 +42,7 @@ public Optional<Boolean> getFlagValue(String id) {
4242 }
4343
4444 @ Override
45- public void startOrResumeClock (String id , @ Nullable String description ) {
45+ public synchronized void startOrResumeClock (String id , @ Nullable String description ) {
4646 var value = statistics .get (id );
4747 if (value instanceof StopClockStatistic clockStatistic ) {
4848 clockStatistic .resume ();
@@ -55,15 +55,15 @@ public void startOrResumeClock(String id, @Nullable String description) {
5555 }
5656
5757 @ Override
58- public void pauseClock (String id ) {
58+ public synchronized void pauseClock (String id ) {
5959 var value = statistics .get (id );
6060 if (value instanceof StopClockStatistic clockStatistic ) {
6161 clockStatistic .pause ();
6262 }
6363 }
6464
6565 @ Override
66- public Optional <Duration > getClockValue (String id ) {
66+ public synchronized Optional <Duration > getClockValue (String id ) {
6767 var value = statistics .get (id );
6868 if (value instanceof StopClockStatistic clockStatistic ) {
6969 return Optional .of (clockStatistic .getElapsed ());
@@ -72,7 +72,7 @@ public Optional<Duration> getClockValue(String id) {
7272 }
7373
7474 @ Override
75- public void increaseCounter (String id , @ Nullable String description , long increment ) {
75+ public synchronized void increaseCounter (String id , @ Nullable String description , long increment ) {
7676 var value = statistics .get (id );
7777 if (value instanceof CounterStatistic counterStatistic ) {
7878 counterStatistic .increase (increment );
@@ -83,12 +83,12 @@ public void increaseCounter(String id, @Nullable String description, long increm
8383 }
8484
8585 @ Override
86- public void setCounter (String id , @ Nullable String description , long count ) {
86+ public synchronized void setCounter (String id , @ Nullable String description , long count ) {
8787 statistics .put (id , new CounterStatistic (id , description , count ));
8888 }
8989
9090 @ Override
91- public Optional <Long > getCount (String id ) {
91+ public synchronized Optional <Long > getCount (String id ) {
9292 var value = statistics .get (id );
9393 if (value instanceof CounterStatistic counterStatistic ) {
9494 return Optional .of (counterStatistic .getCount ());
@@ -97,7 +97,7 @@ public Optional<Long> getCount(String id) {
9797 }
9898
9999 @ Override
100- public void clear () {
100+ public synchronized void clear () {
101101 statistics .clear ();
102102 }
103103
0 commit comments