• 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

doubt i thread mock

 
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi All ,
Which of the following statements are true?

1)A higher priority Thread will prevent a lower priorty Thread from getting any access to the CPU.
2)The yield method only allows any higher priority priority thread to execute.
3)The Thread class has a static method called yield
4)Calling yield with an integer parameter causes it to yield for a specific time.

I think the ans is 1 and 3.but as per the mock we have select one question.
I found this ques in morcus.

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

1)A higher priority Thread will prevent a lower priorty Thread from getting any access to the CPU.

>>> But that is not guaranteed behavior as it depends on OS scheduling.

2)The yield method only allows any higher priority priority thread to execute.

>>> FALSE

3)The Thread class has a static method called yield

>>> YES

4)Calling yield with an integer parameter causes it to yield for a specific time.

>>> BEAUTIFUL LIE; FALSE

Coming to Threads a little is guaranteed due to dependencies with OS.

1. we can use sleep method which will give other threads time to run.
2. join is guaranteed, that means executing thread can wait for particular thread to finish its job.
 
sundar sankar
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks alot
 
You save more money with a clothesline than dozens of light bulb purchases. Tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic