File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Threads and Synchronization and the fly likes Can I synchronize a null object? Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » Threads and Synchronization
Reply Bookmark "Can I synchronize a null object?" Watch "Can I synchronize a null object?" New topic
Author

Can I synchronize a null object?

Nehal Vaidya
Greenhorn

Joined: Jan 18, 2002
Posts: 13
Was asked this question in an interview. Never though about synchronizing a null object till I was asked. :-)


Sun Certified Java 2 Programmer<br />Sun Certified Java 2 Developer<br />Sun Certified Web Component Developer<br />Sun Certified Enterprise Architect (Part I)<br />IBM Websphere Certified
Jim Yingst
Wanderer
Sheriff

Joined: Jan 30, 2000
Posts: 18652
Please take a moment and read our user name policy, and modify your display name accordingly. Thanks.
As for your question, it's easy to test...


"I'm not back." - Bill Harding, Twister
gautam shah
Ranch Hand

Joined: Oct 29, 2000
Posts: 72
Originally posted by Nehal:
Was asked this question in an interview. Never though about synchronizing a null object till I was asked. :-)

101%
even u can synchronized on null literal.
Rob Ross
Bartender

Joined: Jan 07, 2002
Posts: 2205
What does 101% mean?
When I do this, I get a null pointer exception. I am relieved as well, as that was my understanding of what would happen.


Rob
SCJP 1.4
gautam shah
Ranch Hand

Joined: Oct 29, 2000
Posts: 72
Originally posted by Rob Ross:
What does 101% mean?
When I do this, I get a null pointer exception. I am relieved as well, as that was my understanding of what would happen.

200%
 
IntelliJ Java IDE
 
subject: Can I synchronize a null object?
 
Threads others viewed
we know that serialization is null,so is there any advantage using it other than ...
Null is not an instanceof Object
valueOf() method
Question on garbage collection
Generics - Why does it work?
developer file tools