当前位置:网站首页>Multi thread synchronous downloading of network pictures
Multi thread synchronous downloading of network pictures
2022-06-26 05:59:00 【Mr.Rop】
Multi thread synchronous downloading of network pictures
// practice Thread, Realize multi-threaded synchronous downloading of network pictures
public class TestThread2 extends Thread {
private String url; // Network picture address
private String name; // Save network picture file name
// Constructors
public TestThread2(String url, String name) {
this.url = url;
this.name = name;
}
@Override
public void run() {
WebDownLoader webDownLoader = new WebDownLoader();
webDownLoader.downLoader(url,name);
System.out.println(" Downloaded the file named :" + name);
}
public static void main(String[] args) {
TestThread2 t1 = new TestThread2("https://img.alicdn.com/imgextra/i4/6000000001102/O1CN01HJ1Qxo1K0lCQcyutq_!!6000000001102-0-octopus.jpg","1.jpg");
TestThread2 t2 = new TestThread2("https://gtms02.alicdn.com/tps/i2/TB10vPXKpXXXXacXXXXvKyzTVXX-520-280.jpg","2.jpg");
TestThread2 t3 = new TestThread2("https://gtms03.alicdn.com/tps/i3/TB1gXd1JXXXXXapXpXXvKyzTVXX-520-280.jpg","3.jpg");
t1.start();
t2.start();
t3.start();
}
}
// Downloader
class WebDownLoader{
public void downLoader(String url,String name){
try {
FileUtils.copyURLToFile(new URL(url),new File(name));
} catch (IOException e) {
e.printStackTrace();
System.out.println("IO abnormal ,downLoader There is a problem with the method ");
}
}
}
Conclusion : Threads don't have to execute immediately , from CPU To schedule
边栏推荐
- 售前分析
- Pytorch (network model training)
- kolla-ansible部署openstack yoga版本
- 小程序如何关联微信小程序二维码,实现二码聚合
- 循环位移
- [C language] deep analysis of data storage in memory
- Soft power and hard power in program development
- 04. basic data type - list, tuple
- cross entropy loss = log softmax + nll loss
- Redis underlying data structure
猜你喜欢

家庭记账程序(第一版)

5 minutes to learn regular expressions

【C語言】深度剖析數據在內存中的存儲

Test depends on abstraction and does not depend on concrete

421-二叉树(226. 翻转二叉树、101. 对称二叉树、104.二叉树的最大深度、222.完全二叉树的节点个数)

How to use the tablet as the second extended screen of the PC

REUSE_ ALV_ GRID_ Display event implementation (data_changed)

Detailed explanation of serial port communication principle 232, 422, 485

Overloading and overriding

Gram 矩阵
随机推荐
Customize WebService as a proxy to solve the problem of Silverlight calling WebService across domains
Implementation of third-party wechat authorized login for applet
numpy.frombuffer()
Factory method pattern, abstract factory pattern
E-commerce seeks growth breakthrough with the help of small program technology
Redis underlying data structure
冒泡排序(Bubble Sort)
怎么把平板作为电脑的第二扩展屏幕
Func < T, tresult > Commission - learning record
Easy to understand from the IDE, and then talk about the applet IDE
Operator priority, associativity, and whether to control the evaluation order [detailed explanation]
cross entropy loss = log softmax + nll loss
Bingc (inheritance)
numpy. log
原型模式,咩咩乱叫
Prototype mode, Baa Baa
cross entropy loss = log softmax + nll loss
NPM private server problem of peanut shell intranet penetration mapping
转帖——不要迷失在技术的海洋中
机器学习 07:PCA 及其 sklearn 源码解读