Interthread communication

谁都会走 提交于 2019-12-06 16:32:54

That is a totally viable approach to threading. As you probably know, the alternative to polling found in computer hardware is the concept of interrupts.

How would you simulate interrupts in a multithreaded high-level computer program? Hard to say - your thread that changes would have to notify the UI thread "hey I'm ready", rather than the UI thread checking constantly. This requires some sort of message passing, really - it may not be feasible.

That being said, the typical game-design approach is the "game loop" that does, essentially, poll. So there is no shame in that game - you just have to make sure it doesn't murder your performance.

Carlos Grappa

May be this question has an answer for you.

However, polling a queue is a cleaner solution IMHO, and not so costly if done right and there are tons of examples in the Internet.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!