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 Threads on Objects Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Threads and Synchronization
Bookmark "Threads on Objects" Watch "Threads on Objects" New topic
Author

Threads on Objects

vivek dhiman
Ranch Hand

Joined: Aug 05, 2011
Posts: 86




Client is



If client code is inside for loop from 1 to 1000, then if 1000 objects will get unique value???
Muhammad Khojaye
Ranch Hand

Joined: Apr 12, 2009
Posts: 449

So what output comes when you try it?


http://muhammadkhojaye.blogspot.com/
vivek dhiman
Ranch Hand

Joined: Aug 05, 2011
Posts: 86

Output giving me unique records, but will it be safe in future.
Steve Luke
Bartender

Joined: Jan 28, 2003
Posts: 3948
    
  17

I think this was answered in a previous topic of yours. No, time is not unique. If the method gets called multiple times within the same clock tick interval, then the output would be the same. This is more likely to happen in a threaded environment but is also able to happen in a single thread if it is run fast enough.


Steve
Steve Luke
Bartender

Joined: Jan 28, 2003
Posts: 3948
    
  17

vivek dhiman wrote:


Client is



Why are the clients creating an Object instance to access the static method? This is misleading and shouldn't be done. You should do classname.generateIdforDCR();. But your class name should be better (i.e. be descriptive, start with a capital letter).
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Threads on Objects
 
Similar Threads
Reading in different variables
Creating a Shortcut Method for Object Invoking
Objects
Webservice deployment failed
Example for Certification book doesnt work