This week's book giveaway is in the Spring forum.
We're giving away four copies of Spring Boot in Practice and have Somnath Musib on-line!
See this thread for details.
Win a copy of Spring Boot in Practice this week in the Spring 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
  • Tim Cooke
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Liutauras Vilda
  • Henry Wong
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Al Hobbs
  • Carey Brown
Bartenders:
  • Piet Souris
  • Mikalai Zaikin
  • Himai Minh

thread

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

What might cause the current thread to stop executing?
A.

An InterruptedException is thrown
B.

The thread executes a sleep() call
C.

The thread constructs a new Thread
D.

A thread of higher priority becomes ready (runnable)
E.

The thread executes a read() call on an InputStream
to me the ans are:a,b,d
the ans given are:a,b,d,e

help please
sherin
 
Ranch Hand
Posts: 63
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sherin,
During the read() call, the thread is still alive and listening for any input. It only goes into a waiting state. If the thread stops, then it wont be able to read the input. So, e is wrong.
 
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think e is also right.
A thread goes from runnable state to blocked state with any I/O request and waits for the I/O to finish. Once the I/O is finished it goes to ready state and competes, for the processor's attention, with other threads in ready state.
rgds
Sandeep
 
Sandeep Potnis
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
srikrish,
I saw your reply after posting mine. I think it depends what stopping a thread means. Does it mean Drop dead or Stop hogging the CPU ?
thanks Sandep
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic