Browse DevX
Sign up for e-mail newsletters from DevX

Tip of the Day
Language: Java
Expertise: Intermediate
Feb 2, 2001



Building the Right Environment to Support AI, Machine Learning and Deep Learning

Take Control of the Threads Created By a Program

Whenever a thread is created in a program, it is unknown when it will execute. This means there may be cases where the parent program has finished but the thread is still executing. One way to ensure that the main program exits only after the thread is finished with its work is by employing Joins. Join is a member function of the Java thread class.

Write this code at the end of the main thread:

This command will wait until the thread t1 has finished its work.
Shantanu Garg
Comment and Contribute






(Maximum characters: 1200). You have 1200 characters left.



Thanks for your registration, follow us on our social networks to keep up-to-date