Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.help > #2426
| Newsgroups | comp.lang.java.help |
|---|---|
| Date | 2013-01-09 16:59 -0800 |
| References | (5 earlier) <T0lHs.46118$On7.4342@newsfe16.iad> <545e86d1-22b5-42bf-b56f-7c03ac186706@googlegroups.com> <2ZmHs.43434$Sl.37958@newsfe27.iad> <85f704a2-b524-4dc0-abf8-83250d55cc18@googlegroups.com> <kcl38a$kd3$1@dont-email.me> |
| Message-ID | <faf0aa77-0299-48ea-9640-69124203b766@googlegroups.com> (permalink) |
| Subject | Re: Safety Of Non-Synchronized Collections |
| From | Lew <lewbloch@gmail.com> |
markspace wrote: > Lew wrote: >> http://rayfd.me/2007/11/11/when-a-synchronized-class-isnt-threadsafe/ > >> This is elementary concurrency gotcha lore. > > Note this sentence from the article: "Changing the synchronized List to > Vector doesn't help either." Exactly! MY POINT! > Vector is thread safe. Objects wrapped by Collections.synchronized() 'Vector' is *not* thread safe! That's the point of that article. > are thread safe. This does not guarantee that every use of those > classes is safe, or correct. > > Their example is of a single collection which is accessed by multiple > threads. As they show their example produces errors. This is an issue > of atomicity, not thread safety. The single collection is still It is an issue with the idea that people confuse synchronized methods with thread safety. From the Brian Goetz article I quoted upthread: "Thread-safe Thread-safe objects have the properties described above in the section "Thread Safety" -- that constraints imposed by the class's specification continue to hold when the object is accessed by multiple threads, regardless of how the threads are scheduled by the runtime environment, without any additional synchronization. This thread-safety guarantee is a strong one -- many classes, like Hashtable or Vector, will fail to meet this stringent definition." > perfectly safe, in spite of the errors. There are no data races. There are synchronization issues because a person coding that way thinks the synchronized-method class is thread safe when it isn't. You, too, are pulling No True Scotsman, and I will still use Brian Goetz's definitions over yours. > However, the program produces errors because it is poorly designed. It > requires atomicity, and synchronized methods don't provide that across > multiple method calls. Because the class *is not thread safe*! > So the problem is really one of quibbling over terminology. Thread Terminology matters. It's worth "quibbling". (Calling it by something pejorative does not diminish its real importance.) > safety and atomicity both fall under the more general heading of > concurrency and concurrent programming. Thread safety and atomicity are A.k.a., threads. > not the same thing. They overlap a bit, but not much, so it's best to Again, look at the definition and stop changing it. > actually understand what is being discussed. In Java, thread safe means > an absence of data races, but that's all. It says nothing about > atomicity, or the correctness of any given program. Your definition is wrong. -- Lew
Back to comp.lang.java.help | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Safety Of Non-Synchronized Collections Steve <tinker123@gmail.com> - 2013-01-01 15:46 -0500
Re: Safety Of Non-Synchronized Collections Knute Johnson <nospam@knutejohnson.com> - 2013-01-01 14:18 -0800
Re: Safety Of Non-Synchronized Collections Lew <lewbloch@gmail.com> - 2013-01-01 15:43 -0800
Re: Safety Of Non-Synchronized Collections markspace <markspace@nospam.nospam> - 2013-01-01 16:17 -0800
Re: Safety Of Non-Synchronized Collections Lew <lewbloch@gmail.com> - 2013-01-02 11:12 -0800
Re: Safety Of Non-Synchronized Collections markspace <markspace@nospam.nospam> - 2013-01-02 12:56 -0800
Re: Safety Of Non-Synchronized Collections Lew <lewbloch@gmail.com> - 2013-01-02 17:46 -0800
Re: Safety Of Non-Synchronized Collections Roedy Green <see_website@mindprod.com.invalid> - 2013-01-03 05:59 -0800
Re: Safety Of Non-Synchronized Collections Lew <lewbloch@gmail.com> - 2013-01-03 15:30 -0800
Re: Safety Of Non-Synchronized Collections Roedy Green <see_website@mindprod.com.invalid> - 2013-01-09 12:17 -0800
Re: Safety Of Non-Synchronized Collections Lew <lewbloch@gmail.com> - 2013-01-09 12:56 -0800
Re: Safety Of Non-Synchronized Collections Daniel Pitts <newsgroup.nospam@virtualinfinity.net> - 2013-01-09 13:10 -0800
Re: Safety Of Non-Synchronized Collections Lew <lewbloch@gmail.com> - 2013-01-09 14:51 -0800
Re: Safety Of Non-Synchronized Collections Daniel Pitts <newsgroup.nospam@virtualinfinity.net> - 2013-01-09 15:22 -0800
Re: Safety Of Non-Synchronized Collections Lew <lewbloch@gmail.com> - 2013-01-09 16:26 -0800
Re: Safety Of Non-Synchronized Collections Daniel Pitts <newsgroup.nospam@virtualinfinity.net> - 2013-01-09 16:42 -0800
Re: Safety Of Non-Synchronized Collections Lew <lewbloch@gmail.com> - 2013-01-09 16:54 -0800
Re: Safety Of Non-Synchronized Collections Daniel Pitts <newsgroup.nospam@virtualinfinity.net> - 2013-01-10 10:30 -0800
Re: Safety Of Non-Synchronized Collections Lew <lewbloch@gmail.com> - 2013-01-10 10:58 -0800
Re: Safety Of Non-Synchronized Collections markspace <markspace@nospam.nospam> - 2013-01-09 16:50 -0800
Re: Safety Of Non-Synchronized Collections Lew <lewbloch@gmail.com> - 2013-01-09 16:59 -0800
Re: Safety Of Non-Synchronized Collections markspace <markspace@nospam.nospam> - 2013-01-10 08:18 -0800
Re: Safety Of Non-Synchronized Collections Lew <lewbloch@gmail.com> - 2013-01-10 10:49 -0800
Re: Safety Of Non-Synchronized Collections Jukka Lahtinen <jtfjdehf@hotmail.com.invalid> - 2013-01-10 13:37 +0200
Re: Safety Of Non-Synchronized Collections Eric Sosman <esosman@comcast-dot-net.invalid> - 2013-01-10 09:27 -0500
Re: Safety Of Non-Synchronized Collections Jukka Lahtinen <jtfjdehf@hotmail.com.invalid> - 2013-01-10 17:14 +0200
Re: Safety Of Non-Synchronized Collections Eric Sosman <esosman@comcast-dot-net.invalid> - 2013-01-10 11:44 -0500
Re: Safety Of Non-Synchronized Collections Jukka Lahtinen <jtfjdehf@hotmail.com.invalid> - 2013-01-10 23:41 +0200
Re: Safety Of Non-Synchronized Collections Eric Sosman <esosman@comcast-dot-net.invalid> - 2013-01-10 17:14 -0500
Re: Safety Of Non-Synchronized Collections Jukka Lahtinen <jtfjdehf@hotmail.com.invalid> - 2013-01-11 09:10 +0200
Re: Safety Of Non-Synchronized Collections Eric Sosman <esosman@comcast-dot-net.invalid> - 2013-01-11 08:25 -0500
csiph-web