211k views
1 vote
Suppose that a main method encounters the statement t3.join(); Suppose that thread t3's run() method has completed running. What happens?

A. The main method waits for all running threads to complete their run() methods before proceeding.
B. The main method waits for any other thread to complete its run() method before proceeding
C. The main method proceeds to the next statement following the t3.join(); statement
D. Thread t 3 is re-started
E. All threads except t3 that are running are terminated

User Rendon
by
4.9k points

1 Answer

0 votes

Answer:

C. The main method proceeds to the next statement following the t3.join(); statement

Step-by-step explanation:

join() method allows the thread to wait for another thread and completes its execution. If the thread object is executing, then t3.join() will make that t is terminated before the program executes the instruction. Thread provides the method which allows one thread to another complete its execution. If t is a thread object then t.join() will make that t is terminated before the next instruction. There are three overloaded functions.

join()

join(long mills)

join(long millis, int Nanos)

If multiple threads call the join() methods, then overloading allows the programmer to specify the period. Join is dependent on the OS and will wait .

User Kamran Omar
by
4.2k points