• 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 Question

 
Ranch Hand
Posts: 183
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Given the foll Question -



The options are (Choose 1): -

A) Prints "ready to print , now printing" without any exception
B) Prints "ready to print , now printing,printed" without any exception
c) Run time Exception
d) Compiler error

Answer is a).

Should not it be unpredictable bec' result can be either : -

Prints "ready to print , now printing" without any exception OR
Prints "now printing ,ready to print " without any exception


 
Bartender
Posts: 1561
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Simran Dass wrote:
Given the foll Question -




There are too many typos and errors present to tell just what this will do. Even if I fix them to get this to compile, the run method is never called as start is not called on any thread.


Edit:
Except, if you do happen to call start on t immediately after it was created, then you'll see your results.

Question: what object is domore synchronized to? What object gets the called with notifyAll()?
 
Ranch Hand
Posts: 2066
IntelliJ IDE Clojure Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

pete stein wrote:

Simran Dass wrote:
Given the foll Question -




There are too many typos and errors present to tell just what this will do. Even if I fix them to get this to compile, the run method is never called as start is not called on any thread.


Edit:
Except, if you do happen to call start on t immediately after it was created, then you'll see your results.

Question: what object is domore synchronized to? What object gets the called with notifyAll()?



I think, your question should be like this.




Output :
Now printing
Ready to print


And waiting for a notification, since this will not be notified in future, We have to forcefully exit the code.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic