jmx mbean 线程安全
如果我有一个类,它也是一个 mbean,并且我在代码中仅在一个线程中使用该类的函数,并且还通过 jmx 调用函数,我应该同步该代码吗?谢谢
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? thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
代码应该是线程安全的,是的。如果您选择使用
synchronized
使其线程安全,那么这取决于您。通过 JMX 调用的 MBean 将由容器使用其自己的线程来调用,与您自己的代码线程分开。
The code should be thread-safe, yes. If you choose to make it thread-safe using
synchronized
, then that's up to you.MBeans that are invoked via JMX will be invoked by the container, using its own threads, separate from your own code's threads.