Skip to content

Commit 3d396bf

Browse files
committed
DefaultUsageService: add a note on thread safety
Specifically: the lack thereof!
1 parent 3e5d822 commit 3d396bf

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

src/main/java/org/scijava/usage/DefaultUsageService.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,19 @@
4242
import org.scijava.plugin.Plugin;
4343
import org.scijava.service.AbstractService;
4444
import org.scijava.service.Service;
45+
import org.scijava.thread.ThreadService;
4546

4647
/**
4748
* Default service for tracking anonymous usage statistics.
49+
* <p>
50+
* Please note that that this implementation is <em>not</em> thread safe. It is
51+
* up to the caller to ensure that multiple threads do not attempt to modify
52+
* statistics at the same time. One way to do that (but not the only way) is to
53+
* only call {@link #increment(Object)} from the event dispatch thread (i.e.,
54+
* when {@link ThreadService#isDispatchThread()} returns true). And one easy way
55+
* to accomplish that is by calling the {@link UsageService} only from event
56+
* handler methods.
57+
* </p>
4858
*
4959
* @author Curtis Rueden
5060
*/

0 commit comments

Comments
 (0)