public static String getPid ( ) { if ( pid == null ) { String runtimeName = ManagementFactory . getRuntimeMXBean ( ) . getName ( ) ; if ( runtimeName == null ) { pid = "unknown" ; } else { int index = runtimeName . indexOf ( ' ' ) ; if ( index < 0 ) { pid = runtimeName ; } else { pid = runtimeName . substring ( 0 , index ) ; } } } return pid ; }
Retrieves process ID for the current process .