Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

getPID method get current process id improve speed #97

Closed
chenyi19851209 opened this issue Aug 8, 2020 · 0 comments
Closed

getPID method get current process id improve speed #97

chenyi19851209 opened this issue Aug 8, 2020 · 0 comments
Labels
improvement Improve the mechanism or performance

Comments

@chenyi19851209
Copy link
Contributor

getPID method get current process id waste time,because of call
ManagementFactory.getRuntimeMXBean() every time. call only once ok.

public static long getPID() {
String processName = java.lang.management.ManagementFactory.getRuntimeMXBean().getName();
if (processName != null && processName.length() > 0) {
try {
return Long.parseLong(processName.split("@")[0]);
} catch (Exception e) {
return 0;
}
}
return 0;
}

@iNanos iNanos added the improvement Improve the mechanism or performance label Aug 19, 2020
@iNanos iNanos closed this as completed Sep 17, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
improvement Improve the mechanism or performance
Projects
None yet
Development

No branches or pull requests

2 participants