public long getPID ( ) { long currentPID = cachedPID . get ( ) ; if ( currentPID != 0 ) { return currentPID ; } try { currentPID = detectPID ( ) ; } catch ( Throwable cause ) { logger . info ( "Unable to detect process ID!" , cause ) ; } if ( currentPID == 0 ) { currentPID = System . nanoTime ( ) ; if ( ! cachedPID . compareAndSet ( 0 , currentPID ) ) { currentPID = cachedPID . get ( ) ; } } else { cachedPID . set ( currentPID ) ; } return currentPID ; }
Returns the cached PID of Java VM .