#vulnerable code 
                             public void flush() throws IOException {
		ByteBuffer buffer = this.bufferQueue.peek();
		while ( buffer != null ) {
			sockchannel.write( buffer );
			if( buffer.remaining() > 0 ) {
				continue;
			} else {
				synchronized ( bufferQueueTotalAmount ) {
					// subtract this amount of data from the total queued (synchronized over this object)
					bufferQueueTotalAmount -= buffer.limit();
				}
				this.bufferQueue.poll(); // Buffer finished. Remove it.
				buffer = this.bufferQueue.peek();
			}
		}
	} 
                            #location 8 
                            #vulnerability type THREAD_SAFETY_VIOLATION
#fixed code
                             public void flush() throws IOException {
		ByteBuffer buffer = this.bufferQueue.peek();
		while ( buffer != null ) {
			sockchannel.write( buffer );
			if( buffer.remaining() > 0 ) {
				continue;
			} else {
				// subtract this amount of data from the total queued (synchronized over this object)
				bufferQueueTotalAmount.addAndGet(-buffer.limit());
		
				this.bufferQueue.poll(); // Buffer finished. Remove it.
				buffer = this.bufferQueue.peek();
			}
		}
	}