Android faster download of files with Multi thread

前端 未结 2 1033
离开以前
离开以前 2021-01-17 04:43

I\'m working on an app that requires downloading of big video files (300-500MB).
I would like to know if there\'s a way to speed up the download of a single file using m

2条回答
  •  野趣味
    野趣味 (楼主)
    2021-01-17 04:54

    Video can be represented as byte array. If you want to load array faster you can divide it in parts and load every part in separate thread. The best way to do that is using ThreadPoolExecutor to run the task and FutureTask to retrieve results. In case you need to dawnload video from the internet, your server should support api calls that can give you "part" of video. Here is the good sample of how to use Executors and Futures: https://www.journaldev.com/1650/java-futuretask-example-program

提交回复
热议问题