使用java 1.4的异步调用
我正在尝试找到一种使用 1.4 java 框架执行异步调用的简单方法。
这是一个非常简单的示例...运行异步方法,继续在主线程上执行操作,并在异步方法结束时引发事件以获取结果。
我会很感激任何例子,谢谢!
i'm trying to find an easy way to execute an async call using the 1.4 java framework.
It's a very easy example... Run the async method, continue executing actions on main thread an when the async method ends raise an event to get the results.
I'll appreciate any example, thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果您使用 Java 5+,您将使用 Executor 框架。不过,您使用的是 Java 1.4,所以您不能......
但是,Java5 执行器框架实际上是基于预先存在的并发库,从那时起Java5 版本已向后移植到 Java 1.4 (backport-util-concurrent)。
查看
java Java5 中的 .util.concurrent
package 看看它是如何工作的(具体来说,Executors
类)。If you were using Java 5+, you'd use the Executor framework. You're using Java 1.4, though, so you can't....
..... but, the Java5 executor framework is actually based upon a pre-existing concurrency library, and since then the Java5 version has been back-ported to Java 1.4 (backport-util-concurrent).
Check out the
java.util.concurrent
package in Java5 to see how this works (specifically, theExecutors
class).我发现了一篇关于如何处理事件的非常好的帖子:
http://www.javaworld.com/javaworld/javaqa/2002-03/01-qa-0315-happyevent.html?page=1
除此之外,我还发现了一个线程达到我要求的方式。
谢谢!
I found a really good post about how to deal with events:
http://www.javaworld.com/javaworld/javaqa/2002-03/01-qa-0315-happyevent.html?page=1
Besides this and launching a thread i found the way to to what i was asking for.
Thanks!