aspose file tools
The moose likes Threads and Synchronization and the fly likes 'thread-safe'  and  'synchronized' Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


JavaRanch » Java Forums » Java » Threads and Synchronization
Reply Bookmark " Watch " New topic
Author

'thread-safe' and 'synchronized'

kenji kunoichi
Ranch Hand

Joined: Jun 02, 2007
Posts: 39
what is threadSafe and what is synchonised ?


Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 32830
    
    4
Synchronized is a keyword which prevents access to a particular block of code from two threads; it makes it behave as if it were atomic, ie rather like a single-stage procedure. Only one thread can gain access at a time.

Thread safe is a common English description for an object which cannot suffer any problems because of access by two threads at the same time.

Go through the Java Tutorial about concurrency. The Tutorial is required reading!
shankar reddy
Ranch Hand

Joined: Jun 04, 2007
Posts: 71
ThreadSafe can get by using Syncronization. When the Object should be accessed only one request at a time , we can use syncronization.


Java Lover<br /> <br />Shankar Reddy <br />SCJP1.4 (88%)
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 32830
    
    4
There are other ways than synchronisation to make an object thread-safe, eg locking, or an immutable class.
amitabh mehra
Ranch Hand

Joined: Dec 05, 2006
Posts: 98
Originally posted by Campbell Ritchie:
There are other ways than synchronisation to make an object thread-safe, eg locking, or an immutable class.


found a link regarding thread safety by immutable class:
Are Immutable class thread safe
 
I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: 'thread-safe' and 'synchronized'
 
Similar Threads
Unregistered?
Software Life
WA #2 ..... word association
I Always Wanna Post Java Related Topics
World Market