|
Re: Netbeans doesn't like Thread.yield()
You are [coding it correctly]. Hit Alt+Enter on one of the Thread.yield() lines and turn the warning off.
NetBeans complains as Thread.yield() is sometimes used incorrectly. Instead of being used to prevent threads from starving (having one thread take most of the CPU time) like it should be, it can be used with varying degrees of effectiveness to make a statement look atomic (in one piece), e.g. have the thread yield before some operation, to (try to) keep it from being forced to yield in the middle of that operation (which could cause concurrency issues).
If you have to ask, don't worry about it. If it really bugs you and you don't want to just turn it off, you could make your thread sleep for an appropriate amount of time.
|