File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

confusion in join()

 
Rituparna Duttagupta
Ranch Hand
Posts: 55
Firefox Browser Java Netbeans IDE
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi everyone!
please help me to get the join() method correctly.
say, i have 2 threads- t1 and t2. now, if i call t1.join(); inside t2's run() method, then is it that t1 will join after t2? Or t2 will join after t1 completes?
 
Rajasekar Krishnan
Greenhorn
Posts: 16
Java
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Rituparna,



Result:

2T0
2T1
2T2
2T3
2T4
2T5
2T6
2T7
2T8
2T9
2T10
1T0
1T1
1T2
1T3
1T4
1T5
1T6
1T7
1T8
1T9
1T10


When you do join on T2, T1 waits till the T2 to complete its execution, and then T1 continues.


Thanks,
Rajasekar.
 
Rajasekar Krishnan
Greenhorn
Posts: 16
Java
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Rituparna,



Result:

2T0
2T1
2T2
2T3
2T4
2T5
2T6
2T7
2T8
2T9
2T10
1T0
1T1
1T2
1T3
1T4
1T5
1T6
1T7
1T8
1T9
1T10


When you do join on T2 in T1 Run method, T1 waits till the T2 to complete its execution, and then T1 continues.


Thanks,
Rajasekar.
 
Rituparna Duttagupta
Ranch Hand
Posts: 55
Firefox Browser Java Netbeans IDE
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks Rajasekar, now i think i got it.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic