赞
踩
Thread.currentThread().getId()
- //java获取进程ID
- RuntimeMXBean runtime = ManagementFactory.getRuntimeMXBean();
- Field jvm = runtime.getClass().getDeclaredField("jvm");
- jvm.setAccessible(true);
- VMManagement mgmt = (VMManagement) jvm.get(runtime);
- Method pidMethod = mgmt.getClass().getDeclaredMethod("getProcessId");
- pidMethod.setAccessible(true);
- int pid = (Integer) pidMethod.invoke(mgmt);
- InetAddress ia = InetAddress.getLocalHost();
- byte[] mac = NetworkInterface.getByInetAddress(ia).getHardwareAddress();
- String macStr = DatatypeConverter.printHexBinary(mac);
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。