Win a copy of Escape Velocity: Better Metrics for Agile Teams this week in the Agile and Other Processes forum!
  • 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
  • Liutauras Vilda
  • Tim Cooke
  • Paul Clapham
  • Jeanne Boyarsky
Sheriffs:
  • Ron McLeod
  • Frank Carver
  • Junilu Lacar
Saloon Keepers:
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Al Hobbs
  • Carey Brown
Bartenders:
  • Piet Souris
  • Frits Walraven
  • fred rosenberger

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
 
Your mother is a hamster and your father smells of tiny ads!
Garden Master Course kickstarter
https://coderanch.com/t/754577/Garden-Master-kickstarter
reply
    Bookmark Topic Watch Topic
  • New Topic