java中如何处理回调
我有一个 servlet,它使用 http get 从另一台服务器请求地理位置。响应是通过来自其他服务器的回调接收的,并最终到达另一个 servlet。理想情况下,我想在第一个 servlet 上返回一个映射,并使这个异步机制同步。目前我能想到的就是轮询共享哈希图,直到值存在为止,这看起来有点丑陋。我有什么想法可以更优雅地实现这一点吗?
I have a servlet that request a geolocation from another server using an http get. The response is received via a callback from the other server and ends up in another servlet. Ideally I would like to return a map on the first servlet and make this asynchronous mechanism synchronous. All I can come up with at the moment is to poll a shared hashmap till the value is there, it seems like a bit of an ugly hack. Any ideas how I can implement this more elegantly?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在最基本的层面上,使用条件变量比非阻塞循环更有效。
At the most basic level, using a condition variable is more efficient than a non-blocking loop.