Permalink
Browse files

Synchronize threaded quantile recorder

  • Loading branch information...
1 parent 1d9c8bf commit f250639c7e586cab0ed1151b2dc03efb4d815f9e norberthu committed Oct 9, 2012
Showing with 24 additions and 16 deletions.
  1. +24 −16 src/main/java/com/foursquare/heapaudit/recorders/HeapThreadedQuantile.java
@@ -16,8 +16,12 @@
AtomicInteger counter = new AtomicInteger();
- allRegistrations.put(Thread.currentThread().getId(),
- counter);
+ synchronized (allRegistrations) {
+
+ allRegistrations.put(Thread.currentThread().getId(),
+ counter);
+
+ }
return counter;
@@ -37,31 +41,35 @@
String summary = "";
- synchronized (registrations) {
+ synchronized (allRegistrations) {
- synchronized (threadedRecords) {
+ synchronized (registrations) {
- for (Records records: threadedRecords) {
+ synchronized (threadedRecords) {
- summary += "HEAP: " + getId() + " x" + allRegistrations.get(records.id) + " @" + records.id;
+ for (Records records: threadedRecords) {
- ArrayList<Stats> sQuantiles = new ArrayList<Stats>();
+ summary += "HEAP: " + getId() + " x" + allRegistrations.get(records.id) + " @" + records.id;
- flatten(sQuantiles,
- records.quantilesType);
+ ArrayList<Stats> sQuantiles = new ArrayList<Stats>();
- flatten(sQuantiles,
- records.quantilesArray);
+ flatten(sQuantiles,
+ records.quantilesType);
- Collections.sort(sQuantiles);
+ flatten(sQuantiles,
+ records.quantilesArray);
- for (Stats s: sQuantiles) {
+ Collections.sort(sQuantiles);
- summary += "\n - " + s.toString();
+ for (Stats s: sQuantiles) {
- }
+ summary += "\n - " + s.toString();
- summary += "\n";
+ }
+
+ summary += "\n";
+
+ }
}

0 comments on commit f250639

Please sign in to comment.