Java 初学者-java多线程06
今天继续学习了java多线程有关的操作。
public class ThreadTest11 { public static void main(String[] args) { // TODO Auto-generated method stub Thread t=new Thread(new MyRunnabled()); t.setName("t"); t.start(); try { t.join();//t合并到当前线程,当前线程受阻,t线程执行直到结束,并不是栈的合并 } catch (InterruptedException e) { // TODO Auto-generated catch block e.printStackTrace(); } System.out.println("sssss"); } } class MyRunnabled implements Runnable{ public void run() { for(int i=1;i<10000;i++) { System.out.println(Thread.currentThread().getName()+" "+i); } } }
明天计划学习java多线程的线程安全问题。