public static <K, V> V getOrPutSynchronized(ConcurrentMap<K, V> map, K key, final Object mutex,
                                                ConstructorFunction<K, V> func) {
        if (mutex == null) {
            throw new NullPointerException();
        }
        V value = map.get(key);
        if (value == null) {
            synchronized (mutex) {
                value = map.get(key);
                if (value == null) {
                    value = func.createNew(key);
                    map.put(key, value);
                }
            }
        }
        return value;
    }
@Test
    public void testGetOrPutSynchronized() {
        int result = ConcurrencyUtil.getOrPutSynchronized(map, 5, mutex, constructorFunction);
        assertEquals(1005, result);

        assertEquals(1, constructorFunction.getConstructions());
    }