code: func (tp *DocumentsWriterPerThreadPool) release(ts *ThreadState) {
  	tp.Lock()
  	defer tp.Unlock()
  
  	if waitingList := tp.listeners[ts.id]; waitingList != nil && waitingList.Len() > 0 {
  		// this thread state is reserved
  		e := waitingList.Front()
  		waitingList.Remove(e)
  		// re-allocate to external handler
  		e.Value.(chan *ThreadState) <- ts
  		return
  	}
  
  	// push the thread state back to
  	tp.freeList.PushBack(ts.id)
  	tp.hasMoreStates.Signal()
  }
docs: /*
  Release the ThreadState back to the pool. Equals to
  ThreadState.Unlock() in Lucene Java.
  */