Win a copy of Reactive Streams in Java: Concurrency with RxJava, Reactor, and Akka Streams this week in the Reactive Progamming 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Junilu Lacar
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Knute Snortum
  • Tim Cooke
  • Devaka Cooray
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Ganesh Patekar

Threads (from jwhiz)

 
Ranch Hand
Posts: 356
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
This question is from jwhiz. Please take a look at the code and
options.
What will be the output when you compile and execute the following program?



Answer choices:
A. Three times "Threadable: Running.." and three time
"Base: Running.."
B. "Threadable: Running".. in a loop
C. "Base: Running".. in a loop
D. Depends on the Operating System and on Virtual Machine
E. Compilation error: Cannot Implement Runnable interface and extend Thread class at same time.


Given correct choice is A.
But I think the choice D is correct, since which thread will get started will depends on the os.
Can anyone clarify this?
Thanks,
Vanitha.
 
Ranch Hand
Posts: 280
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Even i feel ,correct answer answer is D.
 
Ranch Hand
Posts: 356
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think that A is correct as it will print Three times "Threadable: Running.." and three time
"Base: Running.." , we can not be sure of the order of execution which definately Depends on the Operating System and on Virtual Machine, but in whatever order, it will print as given in option A . Please correct me if I am wrong.
--Farooq

[This message has been edited by Muhammad Farooq (edited September 02, 2001).]
 
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm with Farooq!
// Mathias
 
Vanitha Sugumaran
Ranch Hand
Posts: 356
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for your replies, Leena, Farooq and Mathias.
I agree that it will print 3 times Thread.. and 3 times Base...
I thought in the first choice they are giving importance to the order. That's why I choose choice D because we can't be sure about the order.
Ok, I got to read the choices twice.
Thanks again,
Vanitha.
 
I'm so happy! And I wish to make this tiny ad happy too:
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!