• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

thread join question

 
Ranch Hand
Posts: 95
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Refer to the code below...

I know nothing is truly 'guaranteed' in threading, but in the code example below, is it correct to say that the string "end concurrency" will NEVER be printed before mt1 and mt2 have each finished their run functions?

 
Ranch Hand
Posts: 58
Firefox Browser Windows XP Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello Rachel. I guess you are right with your saying,that string "end concurrency" will NEVER be printed before mt1 and mt2 have each finished their run functions.
As you can see below i executed your code and found that Thread mt2 begins first and ends first followed by Thread mt1 followed by the string "end concurrency"

In thread mt2
In thread mt1
In thread mt1
In thread mt2
In thread mt1
In thread mt2
In thread mt1
In thread mt2
In thread mt1
In thread mt2
end concurrency)

But, as it is shown in the code that, it is thread mt2 that begins first, even though thread mt1 has a much higher priority in fact the highest priority in comparison with that of thread mt2.

Hope this helps!
 
Rachel Glenn
Ranch Hand
Posts: 95
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

sarvesh dikonda wrote:Hello Rachel. I guess you are right with your saying,that string "end concurrency" will NEVER be printed before mt1 and mt2 have each finished their run functions.
As you can see below i executed your code and found that Thread mt2 begins first and ends first followed by Thread mt1 followed by the string "end concurrency"

In thread mt2
In thread mt1
In thread mt1
In thread mt2
In thread mt1
In thread mt2
In thread mt1
In thread mt2
In thread mt1
In thread mt2
end concurrency)

But, as it is shown in the code that, it is thread mt2 that begins first, even though thread mt1 has a much higher priority in fact the highest priority in comparison with that of thread mt2.

Hope this helps!



thank you!
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic