code: private void checkQueue() {
          if (LOG) {
              Log.d(TAG, "- Checking queue");
          }
  
          int activeDownloads = 0;
          for (QueueItem queueItem : queue) {
              if (queueItem.isStarted) {
                  activeDownloads++;
              }
          }
  
          if (activeDownloads >= SIM_MAX_DOWNLOADS) {
              if (LOG) {
                  Log.d(TAG, "- Already have max number of simultaneous downloads");
              }
              return;
          }
  
          QueueItem pendingQueue = null;
          for (QueueItem queueItem : queue) {
              if (!queueItem.isStarted && !queueItem.isStopped) {
                  pendingQueue = queueItem;
                  break;
              }
          }
          if (pendingQueue == null) {
              if (LOG) {
                  Log.d(TAG, "- No work for downloading");
              }
              return;
          }
          if (LOG) {
              Log.d(TAG, "- Starting download file #" + pendingQueue.fileReference.getFileId());
          }
  
          pendingQueue.isStarted = true;
  
          final QueueItem finalPendingQueue = pendingQueue;
          pendingQueue.taskRef = system().actorOf(Props.create(() -> new DownloadTask(finalPendingQueue.fileReference, self(), context())).changeDispatcher("heavy"), "actor/download/task_" + RandomUtils.nextRid());
      }
docs: Queue processing