最近我们游戏经常收到玩家投诉卡进度条的问题。而且后台显示执行队列和CPU使用率异常高
根据调用的JDB分析出 使用xbean 时候会调用以下代码
在设置xmlobject 时候会有一个 GlobalLock.acquire();
当多线程并发设置xmlobject 时候造成互相等待这个GlobalLock 造成各个线程卡住,队列执行效率不高
所以我们目前解决方法就是直接用string 拼接成XML 暂时不用xbean 的功能
public final XmlObject set(XmlObject src) { if (isImmutable()) { throw new IllegalStateException("Cannot set the value of an immutable XmlObject"); } XmlObjectBase obj = underlying(src); TypeStoreUser newObj = this; if (obj == null) { setNil(); return this; } if (obj.isImmutable()) { set(obj.stringValue()); } else { boolean noSyncThis = preCheck(); boolean noSyncObj = obj.preCheck(); if (monitor() == obj.monitor()) { if (noSyncThis) { newObj = setterHelper(obj); } else { synchronized (monitor()) { newObj = setterHelper(obj); } } } else if (noSyncThis) { if (noSyncObj) { newObj = setterHelper(obj); } else { synchronized (obj.monitor()) { newObj = setterHelper(obj); } } } else { if (noSyncObj) { synchronized (monitor()) { newObj = setterHelper(obj); } } boolean acquired = false; try { GlobalLock.acquire(); acquired = true; synchronized (monitor()) { synchronized (obj.monitor()) { GlobalLock.release(); acquired = false; newObj = setterHelper(obj); } } } catch (InterruptedException e) { throw new XmlRuntimeException(e); } finally { if (acquired) { GlobalLock.release(); } } } } return (XmlObject)newObj; }