jmx mbean 线程安全

发布于 2024-08-21 18:06:32 字数 76 浏览 1 评论 0原文

如果我有一个类,它也是一个 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

小红帽 2024-08-28 18:06:32

代码应该是线程安全的,是的。如果您选择使用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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文