• 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
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

Questions on Threads

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

Hi everybody,

Q1) Does giving another thread higher priority stops the execution of the current thread?
Q2) How to find out if a thread is the owner , ie., it owns the lock on the object ?
Q3) Explain why cant u find out if an alive thread is runnable or blocked, or if a runnable thread is actually running, or u cannot differentiate between a thread that has not yet become runnable and one that has already died ?

Q4) Explain join() & yield() methods of the Thread class?
Q5) Waht is the difference between join(), wait(), sleep(), and yield() methods ?
Q6) Explain the following :
When a thread is sleeping it cant actually check whether it should terminate. This is where the interrupt() method comes in. When the interrupt() method is called on a thread object that is currently blocked, the blocking call (such as sleep() or wait() ) is terminated by an InterruptedException.
 
Ranch Hand
Posts: 1070
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
amit, to answer all of these questions would require writing about a chapters worth of notes . Check out RHE or Khalid on there chapters on threads and you will get most of the answers. Also check out the JLS here: http://java.sun.com/docs/books/jls/second_edition/html/memory.doc.html#30206 for some more info on threads.
After reading those and trying a lot of code, pose some spefic questions and/or code problems that you are still have trouble understanding.
I am not trying to avoid you questions, but since you are asking almost every question about threads, it would be too hard to just give a one line answer. That is why I am directing you to more books and info, and then ask questions that can be answered with a short paragraph.
Bill
 
Water! People swim in water! Even tiny ads swim in water:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic