Breaking News: Grepper is joining You.com. Read the official announcement!
Check it out

How can we make sure that Parent thread waits for termination of Child thread?

Pragya Keshap answered on February 4, 2023 Popularity 1/10 Helpfulness 1/10

Contents


More Related Answers

  • Use wait() system call for the parent process to wait for the child to terminate.

  • How can we make sure that Parent thread waits for termination of Child thread?

    0

    We can use join() method for this purpose. On calling join() method,

    current thread waits for the child thread to which it joins to finish.

    Sample code is as follows:

    Thread myThread = new Thread(new Runnable() {

    public void run() {

    }

    });

    myThread.start();

    // Join on myThread

    myThread.join()

    https://www.demo2s.com/java/java-interview-question-parent-thread-waits-for-termination-of-child-t.html

    Popularity 1/10 Helpfulness 1/10 Language java
    Source: Grepper
    Link to this answer
    Share Copy Link
    Contributed on Feb 04 2023
    Pragya Keshap
    0 Answers  Avg Quality 2/10


    X

    Continue with Google

    By continuing, I agree that I have read and agree to Greppers's Terms of Service and Privacy Policy.
    X
    Grepper Account Login Required

    Oops, You will need to install Grepper and log-in to perform this action.