File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes threads Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "threads " Watch "threads " New topic
Author

threads

Mateen Nasir
Ranch Hand

Joined: Aug 01, 2001
Posts: 33
can we have a synchronized intance block or static block
i mean a syn block outside a method
how ?
i have tried and it gives an error
Guoqiao Sun
Ranch Hand

Joined: Jul 18, 2001
Posts: 317
Mateen, seemed we cannot have synchronized instance or static block. We can only synchronize a whole method or part of a method(a block of it).
Regards,

------------------
Guoqiao Sun
Sun Certified Programmer for Java™ 2 Platform
try my mock exam¹²³ at my homepage.


Guoqiao Sun<br />SCJP2 SCWCD2<br />Creator of <a href="http://www.jiris.com/" target="_blank" rel="nofollow">www.jiris.com</a>, Java resource, mock exam, forum
Ragu Sivaraman
Ranch Hand

Joined: Jul 20, 2001
Posts: 464
Yeah you cant have a synchronized instance or static block
It gives a compile time error
Mateen Nasir
Ranch Hand

Joined: Aug 01, 2001
Posts: 33
Thanks a lot
Jane Griscti
Ranch Hand

Joined: Aug 30, 2000
Posts: 3141
Hi Mateen,
You can synchronize on an object using a synchronized block.
See the Sun Tech Tip
Using Synchronized Statements
Hope that helps.

------------------
Jane Griscti
Sun Certified Programmer for the Java� 2 Platform


Jane Griscti
SCJP, Co-author Mike Meyers' Java 2 Certification Passport
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: threads