How Thread.join() method work?? | Sololearn: Learn to code for FREE!
Novo curso! Todo programador deveria aprender IA generativa!
Experimente uma aula grƔtis
0

How Thread.join() method work??

If t1 and t2 are threads are in runnable state if t1.join is called which will undergo waiting state how it actually works??

1st Nov 2022, 7:55 PM
Shreepriya HA
7 Respostas
+ 2
1st Nov 2022, 7:58 PM
Sakshi
Sakshi - avatar
+ 2
java.lang.Thread.join() method makes one thread to wait until another thread completes its execution.
1st Nov 2022, 7:58 PM
I am offline
I am offline - avatar
+ 2
Snehil Pandey Ok thank you
1st Nov 2022, 8:42 PM
Shreepriya HA
+ 1
1st Nov 2022, 8:38 PM
I am offline
I am offline - avatar
0
Snehil Pandey yeah but which thread will wait in multiple threads??
1st Nov 2022, 8:04 PM
Shreepriya HA
0
Shreepriya HA the main one in which the join is called
1st Nov 2022, 8:05 PM
I am offline
I am offline - avatar
0
Snehil Pandey sorry I couldn't get it...Is that mean main thread is t1 here in my example??
1st Nov 2022, 8:10 PM
Shreepriya HA