public Counter get ( String name , int type ) { if ( name == null || name . length ( ) == 0 ) throw new NullPointerException ( "Counter name was not set" ) ; synchronized ( _lock ) { resetIfNeeded ( ) ; Counter counter = _cache . get ( name ) ; if ( counter == null || counter . getType ( ) != type ) { counter = new Counter ( name , type ) ; _cache . put ( name , counter ) ; } return counter ; } }
Gets a counter specified by its name . It counter does not exist or its type doesn t match the specified type it creates a new one .