1 Star 0 Fork 0

oweson/java-script

加入 Gitee
与超过 1400万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
ThreaadPoolTest.java 936 Bytes
一键复制 编辑 原始数据 按行查看 历史
oweson 提交于 2022-06-25 18:01 +08:00 . 添加脚本dockerfile
import java.util.concurrent.Callable;
import java.util.concurrent.Executor;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
/**
* @author oweson
* @date 2022/6/5 16:46
*/
public class ThreaadPoolTest implements Runnable, Callable {
public static void main(String[] args) throws Exception {
ExecutorService executorService = Executors.newFixedThreadPool(4);
executorService.execute(new Thread(new ThreaadPoolTest()));
executorService.execute(new Thread(new ThreaadPoolTest()));
}
@Override
public void run() {
for (int i = 0; i < 10; i++) {
System.out.println(Thread.currentThread().getName()+": "+i);
}
}
@Override
public String call() throws Exception {
for (int i = 0; i < 10; i++) {
System.out.println(Thread.currentThread().getName()+": "+i*i);
}
return "";
}
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/oweson/java-script.git
git@gitee.com:oweson/java-script.git
oweson
java-script
java-script
master

搜索帮助