JiveJdon Community Forums
在线476人   首页   主题表   培训咨询   标签   精华   查搜   注册    登陆 RSS
首页 » 论坛 » Java多线程 集群 并行模式
???en_US.forumThreadPrev.name??? 上一主题
  Go back to the topic 返回本主题   Go back to the topic listing返回主题列表
???en_US.forumThreadNext.name??? 下一主题
Go 总共有 1 回复 / 1
 发表新帖子   回复该主题贴
pushboy

悄悄话
发表文章: 26
注册时间: 2006年05月28日 15:58
thread的notify和wait怎么玩? 2007年01月30日 15:27 到本帖网址 加入本帖到收藏夹 发送到手机 回复该主题
标签列表
我现在是想在系统起来的时候把所有的thread创建起来
然后有请求过来,就唤醒一个thread来干活
可是唤醒之后,这个thread什么事情都没干
这是怎么回事阿

谢谢
pushboy

悄悄话
发表文章: 26
注册时间: 2006年05月28日 15:58
re:thread的notify和wait怎么玩? 2007年01月30日 15:27 到本帖网址 加入本帖到收藏夹 发送到手机 回复该主题
//系统启动时候
for (int i = 0; i < initThreadSize; i++)
{

ServerIThread ServerIthread = new ServerIThread(i);
workThreadsPool.add(ServerIthread);
ServerIthread.start();
synchronized (ServerIthread)
{
try
{
ServerIthread.wait();
}
catch (Exception es)
{
es.printStackTrace();
}
}
}
..............
//有请求过来时候,调用这个方法
synchronized (ServerIthread)
{
ServerIthread.notify();

while (true)
{
boolean isEnd = ServerIthread.isThreadEnd();
if (isEnd)
{
mtMsgMap = ServerIthread.getMtMsgMap();
ServerIthread.wait();
break;
}
}
}
................
//thread的run
public void run()
{
try
{
logger.info("thread " + threadID + " 开始处理...");
isEnd = false;
......
}
}
这个主题有 1 回复 / 1Go
???en_US.forumThreadPrev.name??? 上一主题
  Go back to the topic 返回本主题   Go back to the topic listing返回主题列表    返回页首返回页首
???en_US.forumThreadNext.name??? 下一主题
热点TAG: AOP cache 缓存 DDD EJB 集群 设计模式 Hibernate IOC JiveJdon OO RBAC Seam Spring Struts
正在读取,请等待...
google yahoo 新浪ViVi 365Key网摘 天极网摘 CSDN网摘 添加到百度搜藏 POCO网摘 博采网摘
查询本论坛内 回复超过的热门帖子
     回复该主题贴
标题
 
粗体 斜体 下划线 插入图片 插入代码 插入url链接 插入附件
内容
  发贴前查询 标签列表勿重复发表问题

RSS 手机阅读 add to google add to yahoo
解惑之道在J道 ,打造中国最具影响力的的企业软件社区
OpenSource JIVEJDON v3.0 Powered by JdonFramework Code © 2002-08 jdon.com
anti spam