|
Re: Quick Question about Threads
Sorry, my last post was a bit confusing. What I was trying to say was that using thread.yield() caused the cpu usage to go to 100% but didn't cause any lag. The disadvantage was that it was unpredictable with the vision loop. What we used instead was thread.sleep. This does work for us because waiting 100ms doesn't increase the cpu usage very much. 6-10 fps seems like a good target frame rate for our camera. I don't really understand how the thread.sleep can be improved without making a much more complicated method of threading. I am aware that the sleep function tends to be off because of the way that thread scheduling works, but the difference is so small, that for us it won't really make a difference. We're not waiting for something to happen, we're just trying to reduce CPU usage. I'm trying to keep it simple, and since we only have 3 threads right now including the main thread, and they interact in such a way that they don't need to be synchronized with each other, I don't see why I'd have to do anything differently.
|