我的“看图说话”,欢迎参与!

xiaokang520 2005-07-20 05:10:15
环境:应用服务器部署一个EJB应用。客户端写一个多线程测试程序,现在启了10个线程,下面的结果是控制台输出的一个片断,各位看官能看出些什么来么?
....
thread3>320 Done.
thread5>320 Done.
thread1>320 Done.
thread6>320 Done.
thread4>320 Done.
thread7>320 Done.
thread9>320 Done.
thread10>320 Done.
thread8>320 Done.
thread2>320 Done.
thread3>321 Done.
thread5>321 Done.
thread1>321 Done.
thread6>321 Done.
thread4>321 Done.
thread7>321 Done.
thread9>321 Done.
thread10>321 Done.
thread8>321 Done.
thread2>321 Done.
thread3>322 Done.
thread5>322 Done.
thread1>322 Done.
thread6>322 Done.
thread4>322 Done.
thread7>322 Done.
thread9>322 Done.
thread10>322 Done.
thread8>322 Done.
thread2>322 Done.
thread3>323 Done.
thread5>323 Done.
thread1>323 Done.
thread6>323 Done.
thread4>323 Done.
thread7>323 Done.
thread9>323 Done.
thread10>323 Done.
thread8>323 Done.
thread2>323 Done.
thread3>324 Done.
thread5>324 Done.
......
我很纳闷,不知道是客户端的问题,还是应用服务器中EJB的问题,为什么不是以下这样的结果呢?
thread3>321 Done.
thread5>324 Done.
thread1>319 Done.
thread6>329 Done.
thread4>323 Done.
thread7>325 Done.
thread9>327 Done.
thread10>320 Done.
thread8>326 Done.
thread2>328 Done.
thread3>322 Done.
thread5>351 Done.
thread1>320 Done.
既然是多线程,结果应该是乱的吧...大家看图说话,想想问题在哪里!
...全文
60 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
Kala_Yang 2005-07-20
  • 打赏
  • 举报
回复
应该用SYCONIZE,将RUN方法,加锁。
弘石 2005-07-20
  • 打赏
  • 举报
回复
当然是你的程序作了控制了,贴出程序给大家看看

67,513

社区成员

发帖
与我相关
我的任务
社区描述
J2EE只是Java企业应用。我们需要一个跨J2SE/WEB/EJB的微容器,保护我们的业务核心组件(中间件),以延续它的生命力,而不是依赖J2SE/J2EE版本。
社区管理员
  • Java EE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧