Thread join Usage

1 join () the current thread appears thread1.join () will be executed first and then finish thread1 execution of the current thread

public  static  void main (String [] args) {
         Final the Thread threadN = new new the Thread ( new new Runnable () { 
            @Override 
            public  void RUN () { 
                System.out.println ( "Product managers are planning new requirements ..." ); 
            } 
        }); 

        Final the Thread Thread2 = new new the Thread ( new new the Runnable () { 
            @Override 
            public  void RUN () {
                 the try { 
                    thread1.join (); 
                    System.out.println ( "developers to develop new functional requirements.");
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }
        });

        final Thread thread3 = new Thread(new Runnable() {
            @Override
            public void run() {
                try {
                    thread2.join();
                    System.out.println("测试人员测试新功能");
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }
        });

         
            E.the try { 
            System.out.println ( "product manager to come to work" ); 
            System.out.println ( "testers come to work" ); 
            System.out.println ( "developer to come to work" ); 
            thread1.start (); 
            // after parent calls a child process of the join () method, the parent process to wait for the child process run to completion before continuing to run. 
            System.out.println ( "developers and testers take a break ..." ); 
            thread1.join (); 
            System.out.println ( 
            thread2.start (); 
            System.out.println ( "testers take a break. .. " 
            thread2.join (); 
            thread3.start (); 
        } the catch 
        } 
    }

 

Guess you like

Origin www.cnblogs.com/spring20190213dream/p/10601567.html