同步发送请求
嘿,我在做什么,我必须向雅虎发送请求以获取股票价格。我需要发送的公司名称位于一个数组中,ni 也编码为仅发送 100 个公司请求,但发生的情况是请求一次全部发送,并且由于它不等待响应,因此我仅收到前 100 个公司的响应.如何同步发送请求?还有像锁之类的东西可以用来做到这一点吗?
Hey what i m doing i have to send requests to yahoo for picking up the stock rates. The companies name which i need to send are in an array n i have also coded to send only 100 companies request but what happens is the requests are sending all at a time and since it doesnt wait for the response i get response only for the first 100. how to synchronize sending requests?? Also is there sumthing like a lock which can be used to do it.??
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您需要维护一个队列,其中所有请求一次或在不同时间插入...队列将获取请求执行它并在获得响应后将其从队列中删除。这个循环继续直到队列变空......
you need to maintain a queue in which all request are inserted at once or in different time... Queue will fetch request execute it and remove it from queue after getting response. and this cycle continue till queue gets empty...