• 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

A question about instance init block and threads

 
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This is the question 10 in the book: OCP.Java.SE.6.Programmer.Practice.Exams , practice exam 1,
here is the code,



the answer is : The output could be ted bob alice
so my question is why ted comes before bob, isn't the instance init block comes just after the super() call in the constructor?
or is it because the thread, maybe the thread in the init block can run slower than the one in the constructor?

thanks!
 
Ranch Hand
Posts: 87
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Ruobo,

The output can be bob ted alice also. I am guessing that was not one of the available choices? Probably the other options were incorrect?
 
Ruobo Wang
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

shuba gopal wrote:Hi Ruobo,

The output can be bob ted alice also. I am guessing that was not one of the available choices? Probably the other options were incorrect?



the available answers are:


-
i understand that to correctly answer this one is that carol won't be printing out.
i just wanna make sure if bob ted alice is also a possible output.
thanks shuba
 
shuba gopal
Ranch Hand
Posts: 87
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes, bob ted alice is also a possible output.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic