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

thread mock question

 
Ranch Hand
Posts: 191
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Consider that following code is declared in BussyThread.java file

public class BussyThread extends Thread{
public void run(){
for(int i=0;i<10; i++){
i=i-1;
}//end of for loop
}//end of run()
public static void main(String args[]){
BussyThread b1=new BussyThread();
BussyThread b2=new BussyThread();
b1.start();
b2.start();
}
}//end of class

Above class will start two threads b1 and b2. Select True statements for above class.

A. Only b1 thread will get chance to run
B. Only b2 thread will get chance to run
C. Both thread will get chance to run sharing CPU time
D. Neither of the thread will be able to run.

the answer is A and B. why not C?
 
Ranch Hand
Posts: 377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi vikas,

The execution depends on the implementation of the JVM. As result, either A or B or C is correct.
 
No prison can hold Chairface Chippendale. And on a totally different topic ... my stuff:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic