concurrency issues.
972965
private void makeChoiceCache() {

    if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) JmfTr.entry(this, tc, "makeChoiceCache");

    choiceCache = new int[variants.length];

    if (map == null) {
      for (int i = 0; i < choiceCache.length; i++) {
        choiceCache[i] = -1;
      }
    }
    else {
      for (int i = 0; i < choiceCache.length; i++) {
        choiceCache[i] = map.choiceCodes[i];
      }
    }

    if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) JmfTr.exit(this, tc, "makeChoiceCache");
  }
647932
private void check() {
        for (final Map.Entry<Thread, Long> entry
            : this.threads.entrySet()) {
            final long time = System.currentTimeMillis();
            if (time - entry.getValue() > this.latency) {
                final Thread thread = entry.getKey();
                if (thread.isAlive()) {
                    thread.interrupt();
                }
                this.threads.remove(thread);
            }
        }
    }
606945
public synchronized void flushInsert()
    {
        if (!insertForUpdateList.isEmpty())
        {
            int sent = this.submitInsert(insertForUpdateList);
            if (sent < insertForUpdateList.size())
            {
                this.submitInsertTaskToQueue(this.createInsertTaskForObjects(insertForUpdateList.subList(sent, insertForUpdateList.size())), processedInserts);
            }
            this.insertForUpdateList = new MithraFastList(insertBatchSize);
        }

        if (!insertList.isEmpty())
        {
            int sent = this.submitInsert(insertList);
            if (sent < insertList.size())
            {
                this.submitInsertTaskToQueue(this.createInsertTaskForObjects(insertList.subList(sent, insertList.size())), processedInserts);
            }
            this.insertList = new MithraFastList(insertBatchSize);
        }
    }
517001
function update() {
		while (waiting.length && count < concurrency) (function() {
			var t = waiting.shift()
			
			if (inProg[t.task.id]) {
				inProg[t.task.id].push(t.cb)
				return
			} else {
				inProg[t.task.id] = [t.cb]
				count++
				processor(t.task, function() {
					var args = arguments

					if (!inProg[t.task.id]) return // probably callback called twice
	
					count--
					inProg[t.task.id].forEach(function(cb) { cb.apply(null, args) })
					delete inProg[t.task.id]
	
					setImmediate(update)
				})
			}	
		})()
	}
25987
private static void mult(int[] src, int srcLen, int v0, int v1, int[] dst) {
        long v = v0 & LONG_MASK;
        long carry = 0;
        for (int j = 0; j < srcLen; j++) {
            long product = v * (src[j] & LONG_MASK) + carry;
            dst[j] = (int) product;
            carry = product >>> 32;
        }
        dst[srcLen] = (int) carry;
        v = v1 & LONG_MASK;
        carry = 0;
        for (int j = 0; j < srcLen; j++) {
            long product = (dst[j + 1] & LONG_MASK) + v * (src[j] & LONG_MASK) + carry;
            dst[j + 1] = (int) product;
            carry = product >>> 32;
        }
        dst[srcLen + 1] = (int) carry;
    }
551376
private static void mult(int[] s1, int s1Len, int[] s2, int s2Len, int[] dst) {
        for (int i = 0; i < s1Len; i++) {
            long v = s1[i] & LONG_MASK;
            long p = 0L;
            for (int j = 0; j < s2Len; j++) {
                p += (dst[i + j] & LONG_MASK) + v * (s2[j] & LONG_MASK);
                dst[i + j] = (int) p;
                p >>>= 32;
            }
            dst[i + s2Len] = (int) p;
        }
    }
722417
public static void shuffle (Object[] values, int offset, int length)
    {
        shuffle(values, offset, length, _rnd);
    }
677857
public void flushSomeAvailableRowsFrom(final XMLUtil util, final Appendable appendable,
                                           final int rowIndex) throws IOException {
        this.appender.flushSomeAvailableRowsFrom(util, appendable, rowIndex);
    }
397930
private void ensureAvail(int n) {
    if (pos + n >= buf.length) {
      int newSize = Math.max(pos + n, buf.length * 2);
      buf = Arrays.copyOf(buf, newSize);
    }
  }
1082502
@VisibleForTesting
  void prepareConcurrentMultiGetTasks() {
    multi_get_wait_cnt = 0;
    prepare_multi_get_start_time = DateTime.currentTimeMillis();


    final List<Long> row_base_time_list;
    if (RollupQuery.isValidQuery(rollup_query)) {
      row_base_time_list = prepareRowBaseTimesRollup();
    } else {
      row_base_time_list = prepareRowBaseTimes();
    }

    int next_concurrency_index = 0;
    List<GetRequest> gets_to_prepare = new ArrayList<GetRequest>(batch_size);
    Set<byte[]> tsuids = new ByteSet();
    
    final ByteMap<ByteMap<List<GetRequest>>> all_tsuids_gets;
    if (multiget_no_meta) {
      // prepare the tagvs combinations and base time list
      
      final List<byte[][]> tagv_compinations = prepareAllTagvCompounds();
      all_tsuids_gets = prepareRequestsNoMeta(tagv_compinations, row_base_time_list);
    } else {
      all_tsuids_gets = prepareRequests(row_base_time_list, tags);

    }
    // Iterate over all salts
    for (final Entry<byte[], ByteMap<List<GetRequest>>> salts_entry : all_tsuids_gets.entrySet()) {
      if (gets_to_prepare.size() > 0) { // if we have any gets_to_prepare for previous salt, create a 
                                        // request out of it.
        final MultiGetTask task = new MultiGetTask(tsuids, gets_to_prepare);
        final List<MultiGetTask> mulget_task_list = 
            multi_get_tasks.get((next_concurrency_index++) % concurrency_multi_get);
        mulget_task_list.add(task);
        ++multi_get_wait_cnt;
        multi_get_num_get_requests = multi_get_num_get_requests + gets_to_prepare.size();
        gets_to_prepare = new ArrayList<GetRequest>(batch_size);
        tsuids = new ByteSet();
      }
      byte[] curr_salt = salts_entry.getKey();
      // Iterate over all tsuid's in curr_salt and add them to gets_to_prepare
      for (final Entry<byte[], List<GetRequest>> gets_entry : salts_entry.getValue()) {
        byte[] tsuid = gets_entry.getKey();
      
          for (GetRequest request : gets_entry.getValue()) { 
            if (gets_to_prepare.size() >= batch_size) { // close batch and create a MultiGetTask
              final MultiGetTask task = new MultiGetTask(tsuids, gets_to_prepare);
              final List<MultiGetTask> mulget_task_list = 
                  multi_get_tasks.get((next_concurrency_index++) % concurrency_multi_get);
              mulget_task_list.add(task);
              ++multi_get_wait_cnt;
              multi_get_num_get_requests = multi_get_num_get_requests + gets_to_prepare.size();
              if (LOG.isDebugEnabled()) {
                LOG.debug("Finished preparing MultiGetRequest with " + gets_to_prepare.size() + " requests for salt " + curr_salt + 
                 " for tsuid " + Bytes.pretty(tsuid));
              }
              // prepare a new task list and tsuids
              gets_to_prepare = new ArrayList<GetRequest>(batch_size);
              tsuids = new ByteSet();
            }             
            gets_to_prepare.add(request);
            tsuids.add(gets_entry.getKey());
          }
          tsuids.add(gets_entry.getKey());
      }
    }
   
  
    if (gets_to_prepare.size() > 0) {
      
      final MultiGetTask task = new MultiGetTask(tsuids, gets_to_prepare);
      final List<MultiGetTask> mulget_task_list = 
          multi_get_tasks.get((next_concurrency_index++) % concurrency_multi_get);
      mulget_task_list.add(task);
      ++multi_get_wait_cnt;
      multi_get_num_get_requests = multi_get_num_get_requests + gets_to_prepare.size();
      LOG.debug("Finished preparing MultiGetRequest with " + gets_to_prepare.size());
      gets_to_prepare = new ArrayList<GetRequest>(batch_size);
      tsuids = new ByteSet();
    }

    prepare_multi_get_end_time = DateTime.currentTimeMillis();
    if (LOG.isDebugEnabled()) {
      LOG.debug("Finished preparing concurrency multi get task with " 
          + multi_get_wait_cnt + " tasks using "
          + (prepare_multi_get_end_time - prepare_multi_get_start_time) + "ms");
    }

  }
588459
@Override
    public boolean hasConcurrents() {
        if (concurrents > 0) {
            return true;
        }
        if (CommonUtils.isNotEmpty(methods)) {
            for (MethodConfig methodConfig : methods.values()) {
                if (methodConfig.getConcurrents() != null
                    && methodConfig.getConcurrents() > 0) {
                    return true;
                }
            }
        }
        return false;
    }
849300
function CheckPendingThreadRequests() {
    while (PendingThreadRequests.length) {
        var tq = PendingThreadRequests.shift();
        if (!SendThreadRequest(tq)) {
            // No available thread, we queue the request, again
            PendingThreadRequests.unshift(tq);
            break;
        }
    }
}
1212803
@Override
    public void flushQueueBlocking() {
        flushQueue();

        val context =((CudaContext) AtomicAllocator.getInstance().getDeviceContext().getContext());

        context.syncSpecialStream();
        context.syncOldStream();
    }
1080348
protected void writeReference(long offset, Object reference) {
        assert referenceMessageSize != 0 : "References are not in use";
        // Is there a way to compute the element offset once and just
        // arithmetic?
        UnsafeRefArrayAccess.spElement(references, UnsafeRefArrayAccess.calcElementOffset(offset), reference);
    }
1262471
@Override
  public void flush(boolean forceSync)
      throws IOException {
    if (checksumOut != null) {
      checksumOut.flush();
      if (forceSync && (cout instanceof FileOutputStream)) {
        ((FileOutputStream) cout).getChannel().force(true);
      }
    }
    if (blockDataWriter != null) {
      blockDataWriter.flush();
      if (forceSync) {
        blockDataWriter.force(true);
      }
    }
  }
355854
public void calcOccurrences() {
        State state;
        Iterator iter;
        boolean changes;

        iter = states.iterator();
        while (iter.hasNext()) {
            state = (State) iter.next();
            state.minOcc = 1;
            state.maxOcc = 1;
        }
        do {
            // TODO: iterating in reverse order might be faster
            changes = false;
            iter = states.iterator();
            while (iter.hasNext()) {
                state = (State) iter.next();
                if (state.recalcOccurrence(this)) {
                    changes = true;
                }
            }
        } while (changes);
    }
78924
protected static void multTransABlockMinus_U( double[] dataA, double []dataC,
                                                  int indexA, int indexB, int indexC,
                                                  final int heightA, final int widthA, final int widthC ) {
//        for( int i = 0; i < widthA; i++ ) {
//            for( int k = 0; k < heightA; k++ ) {
//
//                double valA = dataA[k*widthA + i + indexA];
//                for( int j = i; j < widthC; j++ ) {
//                    dataC[ i*widthC + j + indexC ] -= valA * dataA[k*widthC + j + indexB];
//                }
//            }
//        }

        for( int i = 0; i < widthA; i++ ) {
            for( int k = 0; k < heightA; k++ ) {

                double valA = dataA[k*widthA + i + indexA];
                int b = k*widthC + indexB + i;
                int c = i*widthC + indexC + i;

                int endC = (c-i)+widthC;

                while( c != endC ) {
//                for( int j = i; j < widthC; j++ ) {
                    dataC[ c++ ] -= valA * dataA[b++];
                }
            }
        }
    }