Code example for ConcurrentMap

Methods: putIfAbsent

0
        throws AppIDException 
    { 
        if ((application & APP_ID_MASK) != application) {
            throw new InvalidAppIDValueException(application);
        } 
        String oldApp = appIdMap.putIfAbsent(application, appName);
        if (oldApp != null && !oldApp.equals(appName)) {
            throw new AppIDInUseException(application, oldApp, appName);
        } 
    } 
 
    /** 
     * Retrieves the application name registered for the given application id 
     * or null if the application has not been registered 
     * @param application 
     * @return 
     */ 
    public static String getAppName(int application) {
        return appIdMap.get(application);
    } 
}