Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Threads

 
Balaji Bang
Ranch Hand
Posts: 182
Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I have read threads chapter in K & S Book. I understood the topics. but I am not able to answer practical questions in the mock tests. But I am able to answer theoretical questions. But not practical especially Synchronization questions.. Any one please suggest me
 
Ruben Soto
Ranch Hand
Posts: 1032
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The answer is simple: You need to practice more. Go through examples and try to figure them out. It takes a lot of practice, and I am afraid that theoretical knowledge is only a part of the equation.
 
Prav sharma
Ranch Hand
Posts: 102
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Banu Chowdary wrote:Hi,

I have read threads chapter in K & S Book. I understood the topics. but I am not able to answer practical questions in the mock tests. But I am able to answer theoretical questions. But not practical especially Synchronization questions.. Any one please suggest me


I understand. Here are few tips

1. See for sleep, join and wait from within try catch block as they throw Interrupted Exceptions
2. Learn that sleep & yield are static and throw interrupted exception. the ThreadName.sleep and ThreadName.yield don't depend on ThreadName. They act on current thread
3. Learn that wait, notify and notifyall must be called from synchronised context
4. Learn that threads must hold lock on the object on which wait, notify and notifyall is called
5. Synchronised methods don't interefre with Non-synchronised
6. Synchronised methods of threads acting on DIFFERENT Objects won't interefere with one another.


Anyone is free to ADD


 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic