package com.vaguehope.onosendai.util;

import java.util.HashMap;
import java.util.Map;

public class SyncMgr {

	private final Map<String, MutableInt> locks = new HashMap<String, MutableInt>();

	public Object getSync (final String key) {
		synchronized (this.locks) {
			MutableInt c = this.locks.get(key);
			if (c == null) {
				c = new MutableInt();
				this.locks.put(key, c);
			}
			c.i++;
			return c;
		}
	}

	public void returnSync (final String key) {
		synchronized (this.locks) {
			MutableInt c = this.locks.get(key);
			if (c != null) {
				c.i--;
				if (c.i < 1) this.locks.remove(key);
			}
		}
	}

	private static class MutableInt {

		volatile int i = 0;

		public MutableInt () {}

	}

}

@@ -79,16 +79,66 @@
 til.Map;
+%0Aimport java.util.concurrent.atomic.AtomicInteger;
 %0A%0Apublic
@@ -182,26 +182,29 @@
 String, 
-MutableInt
+AtomicInteger
 %3E locks 
@@ -225,26 +225,29 @@
 String, 
-MutableInt
+AtomicInteger
 %3E();%0A%0A%09p
@@ -317,34 +317,37 @@
 locks) %7B%0A%09%09%09
-MutableInt
+AtomicInteger
  c = this.lo
@@ -396,19 +396,23 @@
 new 
-MutableInt(
+AtomicInteger(0
 );%0A%09
@@ -453,10 +453,24 @@
 %09c.i
-++
+ncrementAndGet()
 ;%0A%09%09
@@ -566,26 +566,35 @@
 s) %7B%0A%09%09%09
-MutableInt
+final AtomicInteger
  c = thi
@@ -641,11 +641,25 @@
 %09%09c.
-i--
+decrementAndGet()
 ;%0A%09%09
@@ -667,16 +667,25 @@
 %09if (c.i
+ntValue()
  %3C 1) th
@@ -723,96 +723,6 @@
 %09%7D%0A%0A
-%09private static class MutableInt %7B%0A%0A%09%09volatile int i = 0;%0A%0A%09%09public MutableInt () %7B%7D%0A%0A%09%7D%0A%0A
 %7D%0A

Use AtomicInteger instead of strange int wrapper class.