简体   繁体   English

jmx mbean线程安全

[英]jmx mbean thread safety

if i have a class, that is also a mbean, and i use functions of the class in my code, in only one thread, and also call a function by jmx, should i synchronize that code? 如果我有一个类,那也是一个mbean,并且我在我的代码中使用该类的函数,只在一个线程中,并且还通过jmx调用函数,我应该同步该代码吗? thanks 谢谢

The code should be thread-safe, yes. 代码应该是线程安全的,是的。 If you choose to make it thread-safe using synchronized , then that's up to you. 如果您选择使用synchronized使其成为线程安全的,那么这取决于您。

MBeans that are invoked via JMX will be invoked by the container, using its own threads, separate from your own code's threads. 通过JMX调用的MBean将由容器调用,使用自己的线程,与您自己的代码的线程分开。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM