}
- public synchronized void startSum(String user)
- {
- if (state.containsKey(user))
- throw new IllegalStateException("Sumation for " + user + " already in progress, state: " + state.get(user));
-
- state.put(user, 0l);
- }
-
public synchronized Optional<Long> getSum(String user)
{
return Optional.ofNullable(state.get(user));
state.put(user, result);
}
- public synchronized Long endSum(String user)
+ public synchronized Long calculate(String user)
{
if (!state.containsKey(user))
throw new IllegalStateException("No sumation for " + user + " in progress");