testrunnable.java
来自「本书是一本为Java学习者在基础内容学习结束后进行课程设计时提供参考的指导书」· Java 代码 · 共 31 行
JAVA
31 行
package apibook.c2.s3;public class TestRunnable { public static void main(String[] args) { Thread r=null; for (int i=0;i<4 ;i++ ) { r=new Thread(new cr(i)); r.start(); } }}class cr implements Runnable{ private int k; public cr(int j){ k=j; } public void run(){ for (int i=0;i<1000 ;i++ ) { synchronized(System.out){ System.out.println("cr"+k); try { this.wait(); this.notifyAll(); } catch (Exception ex) { } } } }}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?