开发者

Trying to understand findbugs multithreaded bugs

http://findbugs.sourceforge.net/bugDescriptions.html#SP_SPIN_ON_FIELD is only a problem is the field is not volatile, right?

http://findbugs.sourceforge开发者_开发问答.net/bugDescriptions.html#MDM_WAIT_WITHOUT_TIMEOUT is confusing - what does it mean?


http://findbugs.sourceforge.net/bugDescriptions.html#SP_SPIN_ON_FIELD is only a problem is the field is not volatile, right?

Correct.

http://findbugs.sourceforge.net/bugDescriptions.html#MDM_WAIT_WITHOUT_TIMEOUT is confusing - what does it mean?

I don't see it in the list anymore.


Giving answer to your first ques :-

No SP_SPIN_ON_FIELD is not only related to non volatile instance fields even a volatile field can also lead to this bug.

Plz refer to the code below it has a volatile field and still shows this bug(SP_SPIN_ON_FIELD):-

public class FindBugSP
{
    private volatile int mCountOne = 0;
    /**
     * DEFAULT CONSTRUCTOR
     * 
     */
    private FindBugSP()
    {
        //DO NOTHING
        super();
    }

    /**
     * Method implementing actual scenario of FindBugs bug code - SP 
     */
    void problem()
    {
        while(true)
        {
            if(mCountOne == 0)
            {
                break;
            }
        }
    }

    /**
     *  Method implementing solution for actual scenario of FindBugs bug code - SP
     */
    void solution()
    {
        while(true)
        {
            if(mCountOne ==5)
            {
                break;
            }
            mCountOne++;
        }
   }

}

Now answering your second ques:- MDM_WAIT_WITHOUT_TIMEOUT has been removed from the list of bugcodes.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜