View Single Post
  #2   Spotlight this post!  
Unread 01-26-2011, 09:59 PM
sjspry sjspry is offline
Registered User
FRC #1984
Team Role: Programmer
 
Join Date: Jan 2011
Rookie Year: 2010
Location: Kansas
Posts: 125
sjspry has a spectacular aura aboutsjspry has a spectacular aura aboutsjspry has a spectacular aura about
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.
Reply With Quote