十年网站开发经验 + 多家企业客户 + 靠谱的建站团队
量身定制 + 运营维护+专业推广+无忧售后,网站问题一站解决
Java join线程在使用的时候需要我们不断的学习相关编程的知识。下面我们就先来看看有关Java join线程的源代码。只有这样才能更好的进行相关问题的解决,希望大家有所收获。

创新互联建站专注于和静企业网站建设,响应式网站,商城系统网站开发。和静网站建设公司,为和静等地区提供建站服务。全流程按需设计,专业设计,全程项目跟踪,创新互联建站专业和态度为您提供的服务
使调用join()的线程执行完毕后才能执行其它线程,在一定意义上,它可以实现同步的功能。
- class TestThreadMethod extends Thread{
- public static int shareVar = 0;
- public TestThreadMethod(String name){
- super(name);
- }
- public void run(){
- for(int i=0; i<4; i++){
- System.out.println(" " + i);
- try{
- Thread.sleep(3000);
- }
- catch(InterruptedException e){
- System.out.println("Interrupted");
- }
- }
- }
- }
- public class TestThread{
- public static void main(String[] args){
- TestThreadMethod t1 = new TestThreadMethod("t1");
- t1.start();
- try{
- t1.join();
- }
- catch(InterruptedException e){}
- t1.start();
- }
- }
以上就是对Java join线程源代码的相关介绍。