Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Synchronizing mechanisms

 
Please Duvall
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,
I looking for some material covering typical synchronizing problems,
*errors that programmers usually do* and how to solve these typical errors.
I'm using both Java & C++ for programming.
Thanks!
 
Stan James
(instanceof Sidekick)
Ranch Hand
Posts: 8791
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Doug Lea "wrote the book" on threads in Java. The Sun tutorial on threads is also pretty good. Dig into those for a start, be sure to ask here again if you find specific questions. It's a tricky area - expect to be a bit confused for a while.
Lea's Concurrent Package This stuff is a bit advanced and rather under-documented as a learning tool.
Lea's Home Page. Has a link to the book.
Sun Tutorial
Hmmm, editing again. Those were introductory pointers to threads, but didn't really answer your question. In your reading, keep an eye out for:
Deadly embrace: Thread one holds a lock on resource A and is trying to get resource B, while thread two holds a lock on B and is trying to get A. This happens on the street: I can't turn left until a car moves, and the car can't move until somebody behind me moves and he can't move until I turn left.
Race: Thread one and thread two are reading and writing the same resource, clobbering each other's values as they go. Neither one gets correct results.
Rendezvous: The main thread spins off a bunch of tasks and wants to know when they are all done.
Thread pools: The main thread runs many thousands of tasks over time. Imagine a web server servicing each request on a thread. The overhead of creating new threads can be a problem. Running too many at the same time can be a problem. A thread pool can throttle the tasks to a reasonable number at once and reuse threads instead of creating new ones.
Look at the classes in Doug Lea's concurrent package. Try to imagine other problems he set out to solve.
[ April 07, 2004: Message edited by: Stan James ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic