显然是需要同步处理的.你可以定义一个Service,例如:interface BallService {
void addTeam(String teamname) throws OutofQueueException;
}public class DefaultService {
private final static _ins = new DefaultService(); public static DefaultService getInstance(){return _ins;} public synchronized void addTeam(String teamname) throws OutofQueueException {
........
}
}在你的Aciton中每接收到一个用户请求,立即通过getInstance().addTeam("yourteam name")来处理,当有OutofQueueException时即提示用户已满.
void addTeam(String teamname) throws OutofQueueException;
}public class DefaultService {
private final static _ins = new DefaultService(); public static DefaultService getInstance(){return _ins;} public synchronized void addTeam(String teamname) throws OutofQueueException {
........
}
}在你的Aciton中每接收到一个用户请求,立即通过getInstance().addTeam("yourteam name")来处理,当有OutofQueueException时即提示用户已满.
解决方案 »
- hql连接两个属性方法
- sql 事务 问题
- MyEclipse反向工程和Hibernate映射关系的问题..................................................
- 通过Sping提供的HibernateTemplate类,如何删除外键关联
- 关于hibernate的查询问题
- java中如何遍历map中有嵌套的list
- 小弟在在csdn寻觅高手,愿意拜他为师~
- 请问bean:messge标签用到的key是在什么地方用到的?譬如下面的index.title
- JComboBox如何读取数据库里的数据并填充到JComboBox里.????
- 起动Java Application Server时的问题
- 在文本框的onChange事件里可以改变applet的 param的值吗?怎么改?
- 急..向高手请教,在线等,一经解决立刻结贴
楼上的为什么要把DefaultService设计成单件模式呢,直接用静态方法调用addTeam不更方便??