public void setFragmentBuilder ( FragmentBuilder builder ) { FragmentBuilder currentBuilder = builders . get ( ) ; if ( currentBuilder == null && builder != null ) { int currentCount = threadCounter . incrementAndGet ( ) ; int builderCount = builder . incrementThreadCount ( ) ; if ( log . isLoggable ( Level . FINEST ) ) { log . finest ( "Associate Thread with FragmentBuilder(2): Total Thread Count = " + currentCount + " : Fragment Thread Count = " + builderCount ) ; synchronized ( threadNames ) { threadNames . add ( Thread . currentThread ( ) . getName ( ) ) ; } } } else if ( currentBuilder != null && builder == null ) { int currentCount = threadCounter . decrementAndGet ( ) ; if ( log . isLoggable ( Level . FINEST ) ) { log . finest ( "Disassociate Thread from FragmentBuilder(2): Total Thread Count = " + currentCount ) ; synchronized ( threadNames ) { threadNames . remove ( Thread . currentThread ( ) . getName ( ) ) ; } } } else if ( currentBuilder != builder ) { int oldCount = currentBuilder . decrementThreadCount ( ) ; int newCount = builder . incrementThreadCount ( ) ; if ( log . isLoggable ( Level . FINEST ) ) { log . finest ( "WARNING: Overwriting thread's fragment builder: old=[" + currentBuilder + " count=" + oldCount + "] now=[" + builder + " count=" + newCount + "]" ) ; } } builders . set ( builder ) ; }
This method sets the builder for this thread of execution .