MultiThreadedApplicationAdapter 中的同步方法

发布于 2024-12-01 15:23:52 字数 837 浏览 3 评论 0原文

我在 mmo 中使用 red5,并且我在同步方法方面遇到了麻烦,我在 MultiThreadedApplicationAdapter 中使用的方法总是阻止下一个请求。正常吗?因为我正在这些方法中执行一些数据库操作,并且这个同步块使我的性能非常差。我决定使用石英作业来克服这个问题,然而这次集群拓扑让我感到困惑。您能帮我一下吗,使用石英来解决这个问题是一个常见的解决方案吗?有没有人可以给我一个更明智的建议? 谢谢,

我想补充一下以澄清我的问题

在扩展 MultiThreadedApplicationAdapter 并创建我的重写类之后,我实现了

public  boolean connect(IConnection conn, IScope scope, Object[] params) {

函数,在这个函数中我想在线设置用户状态(如您所见,该函数中没有任何同步文字)它的作用就如存在的那样。) 我想从数据库中获取用户实体,然后设置在线状态,然后将其保存回来 在这一部分中,即使我不使用同步文字,下一个即将到来的客户端也会等待上一个完成。我觉得我必须使用 Quartz 创建另一个作业并在该线程中进行数据库操作,但是我不确定这会降低我的性能。有没有其他方法可以防止这个阻止,这似乎是 Red5 的限制? 这也在博客 http://ria101.wordpress.com/2010/03/09/red5-cabin-fever-advanced-scope-and-room-management/

I am using red5 for mmo , and I am in trouble with syncronized methods , the methods which i used in MultiThreadedApplicationAdapter always blocking next request. Is it normal ? Because i am doing some database operations in these methods and this syncronized block is making my performance very poor. I decided to use quartz jobs to overcome this stuation, how ever this time clustered topolgy is making me confused . Could you please help me , is it a common solution to use quartz for this problem , is there any body to give me a smarter advice
Thank you

I want to make an addition to clear my question

After extending MultiThreadedApplicationAdapter and create my overriden class , I implemented

public  boolean connect(IConnection conn, IScope scope, Object[] params) {

function and in this function I want to set user status Online (As you can see there is not any syncronized literal in this function however it is acting as there is.)
And I want to take user entity from database and then set online status and then save it back
In this part even if I dont use syncronized literal , next coming client is waiting previous completed. I feel like I must create another job with Quartz and make database operations in that thread however I am not sure this decrease my performance. Is there any other way to prevent this block , this seems to be a Red5 limitation ??
This is also mentioned in a blog http://ria101.wordpress.com/2010/03/09/red5-cabin-fever-advanced-scope-and-room-management/

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(1

倾城花音 2024-12-08 15:23:52

只有一个线程可以调用对象的同步方法,石英不会改变它。从你的帖子来看,这似乎并不是你想要实现的目标。

Only one thread can invoke synchronized method of an object, an quartz won't change it. And from your post doesn't seem what you want to achieve.

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