News for hackers. Stuff that matters.
Re:Ask HN : Have you ever programmed with threads? by Quarrelsome on Friday March 05, 2010 @04:32PM (#1170540)
"or just put synchronized everywhere"

Won't you deadlock this way?

Re:Ask HN : Have you ever programmed with threads? by jbooth on Friday March 05, 2010 @04:44PM (#1170568)
Depends on what you're doing. Synchronized locks on the instance (or class if you're using a static method) and the locks are reentrant -- a thread holding a lock can reacquire it as many times as it wants.

But yeah my comment was a little imprecise :) If you're using a bunch of different objects which have interactions, using synchronized "everywhere" could very well lead to a deadlock :)

Re:Ask HN : Have you ever programmed with threads? by GrandMasterBirt on Friday March 05, 2010 @05:29PM (#1170661)
That statement was oversimplified. Its funny I've actually hit head on people who didnt understand "critical sections" and such and just added synchronized everywhere and even that didnt help because they were locking an independent object vs a shared object that had to be locked in order to create a critical section.

So yea read up on multithreading, its extremely important to know, but hey my friend worked 4 yrs in .net and just started learning multithreading. So its not always needed.