Hum*_*ing 1 java spring multithreading spring-mvc quartz-scheduler
我正在使用Spring 3.2进行Java聊天项目.
通常在Java中我可以创建一个这样的线程:
public class Listener extends Thread{
public void run(){
while(true){
}
}
}
Run Code Online (Sandbox Code Playgroud)
然后启动线程start().
但是Spring 3.x有没有特殊的类或任何特殊的方法来实现线程功能?
我有2个电信域服务器.在我的应用程序中,我需要初始化服务器以创建协议.
初始化服务器后,我需要启动两个线程来监听来自电信域服务器的响应.
我所做的工作如下:
public class Listener extends Thread{
public void run(){
while(true){
if(ServerOne.protocol != null){
Message events = ServerOne.protocol.receive();
//Others steps to display the message in the view
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
有可能用java做线程功能quartz吗?
如果可能哪一个更好?如果没有意思,是什么原因?
希望我们的堆栈成员能提供更好的解决方案.
小智 6
Spring的TaskExecutor是在托管环境中运行这些线程的好方法.您可以参考http://static.springsource.org/spring/docs/3.0.x/reference/scheduling.html获取一些示例.
| 归档时间: |
|
| 查看次数: |
5930 次 |
| 最近记录: |