0

How to ensure all threads that started from main must end in order in which they started and main should end last? (I am new in learning thread in Java). Is there any builtin method

1 Answer 1

1

main can call Thread.join on the threads it explicitly starts.

Threads will end on their own accord. What would it mean to keep a thread alive if it was no longer running any code?

You might want each thread to keep running an event loop, checking each iteration (and waiting when idle) on a counter to see whether its number is up. But that would be weird.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.