没有合适的资源?快使用搜索试试~ 我知道了~
JavaSE程序设计课件:L06-Multithreading - 1.pdf
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 69 浏览量
2022-06-18
20:05:19
上传
评论
收藏 424KB PDF 举报
温馨提示
试读
32页
JavaSE程序设计课件:L06-Multithreading - 1.pdf
资源推荐
资源详情
资源评论
Chapter 19
Multithreading
Threads Concept
Multiple
threads on
multiple
CPUs
Multiple
threads
sharing a
single CPU
Thread 3
Thread 2
Thread 1
Thread 3
Thread 2
Thread 1
Creating Threads
by Extending the Thread class
// Custom thread class
public class CustomThread extends Thread {
...
public CustomThread(...) {
...
}
// Override the run method in Thread
public void run() {
// Tell system how to run custom thread
...
}
...
}
// Client class
public class Client {
...
public void someMethod() {
...
// Create a thread
CustomThread thread1 = new CustomThread(...);
// Start a thread
thread1.start();
...
// Create another thread
CustomThread thread2 = new CustomThread(...);
// Start a thread
thread2.start();
}
...
}
java.lang.Thread
CustomThread
Creating Threads by Implementing the Runnable Interface
// Custom thread class
public class CustomThread
implements Runnable {
...
public CustomThread(...) {
...
}
// Implement the run method in Runnable
public void run() {
// Tell system how to run custom thread
...
}
...
}
// Client class
public class Client {
...
public void someMethod() {
...
// Create an instance of CustomThread
CustomThread customThread
= new CustomThread(...);
// Create a thread
Thread thread = new Thread(customThread);
// Start a thread
thread.start();
...
}
...
}
java.lang.Runnable
CustomThread
剩余31页未读,继续阅读
资源评论
智慧安全方案
- 粉丝: 3614
- 资源: 59万+
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功