当前位置:网站首页>3. Practice the Thread
3. Practice the Thread
2022-08-09 09:33:00 【come here my bear】
Thread, netmap download
package com.xiancheng.demo;import org.apache.commons.io.FileUtils;import java.io.File;import java.io.IOException;import java.net.URL;// Practice Thread to achieve multi-threaded synchronous download of pictures// inherit Thread class// Override the run() method// run the start() methodpublic class TestThread2 extends Thread{private String url; // network image addressprivate String name; // saved file addresspublic TestThread2(String url, String name){this.url = url;this.name = name;}public TestThread2() {}// Download the executor of the image [email protected] void run() {WebDownloader webDownloader = new WebDownloader();webDownloader.downloader(url, name);System.out.println("The downloaded file name is: " + name);}public static void main(String[] args) {TestThread2 testThread2 = new TestThread2("https://tse2-mm.cn.bing.net/th/id/OIP-C.2rQ25qnSMQHXGcHz3Rp2pAHaEo?w=277&h=180&c=7&r=0&o=5&dpr=1.25&pid=1.7","2.jpg");TestThread2 testThread3 = new TestThread2("https://tse2-mm.cn.bing.net/th/id/OIP-C.2rQ25qnSMQHXGcHz3Rp2pAHaEo?w=277&h=180&c=7&r=0&o=5&dpr=1.25&pid=1.7","3.jpg");TestThread2 testThread4 = new TestThread2("https://tse2-mm.cn.bing.net/th/id/OIP-C.2rQ25qnSMQHXGcHz3Rp2pAHaEo?w=277&h=180&c=7&r=0&o=5&dpr=1.25&pid=1.7","4.jpg");testThread2.start();testThread3.start();testThread4.start();}}class WebDownloader{// download methodpublic void downloader(String url, String name){try {FileUtils.copyURLToFile(new URL(url),new File(name));} catch (IOException e) {e.printStackTrace();System.out.println("IO exception, there is a problem with the downloader method");}}}边栏推荐
- Environment build onnxruntime 】
- WAVE SUMMIT 2022深度学习开发者峰会
- 米斗APP逆向分析
- [Environmental Construction] tensorrt
- How much do you know about the mobile APP testing process specifications and methods?
- [Machine Learning] Basics of Data Science - Basic Practice of Machine Learning (2)
- Ontology Development Diary 01-Jena Configuration Environment Variables
- 记录一次被入侵5900端口经历
- 功能自动化测试实施的原则以及方法有哪些?
- 手机APP测试流程规范和方法你知道多少?
猜你喜欢
随机推荐
用户设备IP三者绑定自动上号
年薪40W测试工程师成长之路,你在哪个阶段?
1. Introduction to threads
本体开发日记05-努力理解SWRL(中)
本体开发日记03-理解代码
6.Map接口与实现类
第四讲 SVN
div模拟textarea文本框,输入文字高度自适应,且实现字数统计和限制
选择黑盒测试用例设计方法的综合策略方案总结
游戏测试的概念是什么?测试方法和流程有哪些?
条件和递归
一篇文章让你彻底搞懂关于性能测试常见术语的定义
Ontology Development Diary 03 - When debugging is in progress
JMeter参数化4种实现方式
“摄像头用不了”+win8.1+DELL+外置摄像头+USB免驱的解决办法
软件测试个人求职简历该怎么写,模板在这里
白盒测试的概念、目的是什么?及主要方法有哪些?
本体开发日记05-努力理解SWRL(Usage Suggestions)
Environment build onnxruntime 】
Firebase+Facebook 授权 web 登录提示域名验证或跳转错误



