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线程源代码的相关介绍。
网站题目:Javajoin线程源代码全面透析
文章转载:http://www.shufengxianlan.com/qtweb/news17/20667.html
网站建设、网络推广公司-创新互联,是专注品牌与效果的网站制作,网络营销seo公司;服务项目有等
声明:本网站发布的内容(图片、视频和文字)以用户投稿、用户转载内容为主,如果涉及侵权请尽快告知,我们将会在第一时间删除。文章观点不代表本网站立场,如需处理请联系客服。电话:028-86922220;邮箱:631063699@qq.com。内容未经允许不得转载,或转载时需注明来源: 创新互联