开发者

multiple move operations and data processes in work thread

开发者 https://www.devze.com 2022-12-25 16:07 出处:网络
main thread--> start workthread-->StartStage(get lis开发者_如何学Got of positions for data process) --> move to one position --> data sampling --> data collection-->data analysis------>data sampling

main thread--> start workthread-->StartStage(get lis开发者_如何学Got of positions for data process) --> move to one position --> data sampling --> data collection-->data analysis------>data sampling

basically, work thread does the data sampling --> data collection-->data analysis------>data sampling loop for one positioin until press stop or target is obtained.

my questions:

After work thread finishs the loop for one positioin, it would end itself.

now how to make the work thread moves to the next position to do the data process loop after work thread finish one position work, would not end itself until data process for all the positions are done?

Thanks in advance!


  • Make a ConcurrentQueue<> with all the positions
  • At the end of a position let a workerthread Dequeue a new position from the ConcurrentQueue<> and process it. This can be a simple while loop.
  • If the Dequeue fails there are no more positions and the thread exits
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号