• 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

Thread3

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

Which is a possible result of attempting to compile and run the program?

a. Prints a number that is less than 1000
b. Prints a number between 1000 and 9999
c. Prints a number larger than 10000
d. Compile-time error
e. Run-time error
f. None of the above



can anyone explain me whats happening in the above code?
[ November 29, 2005: Message edited by: Mark Spritzler ]
 
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think it should give you a compiler error because you shuld enclose
the sleep() in a try catch block or atleast declare it even if you are not handling it
 
achayya matta
Ranch Hand
Posts: 111
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i know preetha it produces a compile time error,plz ignore that and explain me the flow of the program please
 
Ranch Hand
Posts: 99
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I gone thru SUN java tutorial and Thread API, from that what my understanding is a thread is interruptible when it is in NOT RUNNABLE status.

NOT RUNNABLE status is defined as one of the following

1. In sleep
2. In wait
3. In Blocked IO/ waiting for IO
4. IN wait for other thread to complete(i.e join())

when yield method is called, still the thread is in RUNNABLE status. interrupt has no effect on a RUNNABLE thread.

I am not 100 % sure about the above theory, but I tried simulating the above conditions and worked as explained.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic