Add method to pass thread-indicator via an extra argument.

This commit is contained in:
asofold 2017-04-26 18:45:28 +02:00
parent 65fc88f41a
commit 7d7a0bf010

View File

@ -115,6 +115,23 @@ public class Counters {
}
}
/**
* Convenience: pass state via a boolean.
*
* @param id
* @param count
* @param isPrimaryThread
* Must be correct.
*/
public void add(int id, int count, boolean isPrimaryThread) {
if (isPrimaryThread) {
ptCounts[id].count ++;
}
else {
addSynchronized(id, count);
}
}
/**
* Only call from the primary thread.
*