File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Beginning Java and the fly likes Synchronized blocks Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Synchronized blocks" Watch "Synchronized blocks" New topic

Synchronized blocks

Fitz Herbert

Joined: Mar 22, 2003
Posts: 21
can they be nested?
Rob Ross

Joined: Jan 07, 2002
Posts: 2205
Well, you could try nesting them and see what the compiler tells you!

SCJP 1.4
Michael Morris
Ranch Hand

Joined: Jan 30, 2002
Posts: 3451
can they be nested?
Yes, but what's the point unless you are synchronizing different objects? Even so, it's risky, a deadlock waiting to happen.

Any intelligent fool can make things bigger, more complex, and more violent. It takes a touch of genius - and a lot of courage - to move in the opposite direction. - Ernst F. Schumacher
Fitz Herbert

Joined: Mar 22, 2003
Posts: 21
Nicholas Turner
Ranch Hand

Joined: May 24, 2003
Posts: 126
Yeah really quite funny. Like especially if Objecta synchronizes a recursive function.
Ha ha it will deadlock itself. I think. It would be even funnier if I didnt know what I was talking about
I agree. Here's the link:
subject: Synchronized blocks
It's not a secret anymore!