java download multiple files using threads

后端 未结 5 1907
庸人自扰
庸人自扰 2020-11-30 02:54

I am trying to download multiple files that matches a pattern using threads. The pattern could match 1 or 5 or 10 files of diff sizes.

lets say for simplicity sake

5条回答
  •  旧巷少年郎
    2020-11-30 03:10

    Yes you can create the Threads inline.

    for (final String name : fileNames){
        new Thread() {
           public void run() {
               downloadFile(name, toPath);
           }
        }.start();
    }
    

提交回复
热议问题