/**
  * Thread to download files Take all the webLinkedFile contained in the htmlFileToDownload list
  * and download them
  */
 public void run() {
   testIfPaused();
   DownloadAndParseFile downloadFile;
   boolean isInterrupted = false;
   while (!Thread.interrupted()
       && (htmlFileToDownload.isEmpty() == false
           || linkedFileToDownload.isEmpty() == false
           || htmlFileInDownloading.isEmpty() == false
           || linkedFileInDownloading.isEmpty() == false)) {
     if (currentDLHtml < maxDLHtml && htmlFileToDownload.isEmpty() == false) {
       WebHtmlFile webHtmlFile;
       webHtmlFile = htmlFileToDownload.get(0);
       this.htmlFileToDownload.remove(0);
       if (webHtmlFile.getProgression() != -1) { // was not cancelled
         htmlFileInDownloading.add(webHtmlFile);
         // start a new download of Html File in a new Thread
         downloadFile = new DownloadAndParseFile(this, webHtmlFile, defaultHost, destDirectory);
         downloadFile.start();
         threadList.add(downloadFile);
         currentDLHtml++;
       }
     }
     testIfPaused();
     if (currentDLLink < maxDLLink && linkedFileToDownload.isEmpty() == false) {
       WebLinkedFile webLinkedFile;
       webLinkedFile = linkedFileToDownload.get(0);
       this.linkedFileToDownload.remove(0);
       if (webLinkedFile.getProgression() != -1) { // was not cancelled
         linkedFileInDownloading.add(webLinkedFile);
         // start a new download of Linked File in a new Thread
         downloadFile = new DownloadAndParseFile(this, webLinkedFile, defaultHost, destDirectory);
         downloadFile.start();
         threadList.add(downloadFile);
         currentDLLink++;
       }
     }
     try {
       Thread.sleep(HtmlConstants.TIME_BETWEEN_EACH_DOWNLOAD);
     } catch (InterruptedException e) {
       interrupt();
       isInterrupted = true;
     }
   }
   if (!isInterrupted) {
     // End of Download (successfull)
     JOptionPane.showMessageDialog(
         JHMainFrame.getInstance(),
         Labels.DOWNLOAD_FINISHED_LABEL,
         Labels.DOWNLOAD_STATUS_LABEL,
         JOptionPane.INFORMATION_MESSAGE);
   }
   // free the DownloadManager
   freeDownloadManager();
 }