My code:
String[] torrentFiles = new File("/root/torrents/").list();
        if(torrentFiles.length == 0 || torrentFiles == null)
        {
            System.exit(0);
        }
        ex = Executors.newFixedThreadPool(3);
        for(String torrentFile : torrentFiles)
        {
            ex.submit(new DownloadTorrent("/root/torrents/" + torrentFile));
        }
        ex.shutdown();
        try
        {
            ex.awaitTermination(30, TimeUnit.MINUTES);
        }
        catch(InterruptedException ex1)
        {
            Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex1);
        }
But sometimes torrent downloading takes unknown time value and «awaitTermination» not works as I want. I need to stop all executed threads instantly after half an hour but as I know «awaitTermination» just only use interrupt() method which works only in loops or waiting. So timeout not works if this moment happens. So, how to?
 
     
     
     
     
     
     
     
    