On Wed, Aug 20, 2003 at 10:25:39AM -0400, Henri Yandell wrote: > > > FastXxx classes say that they are not cross-platform, but in no way > > > discuss which platforms they are targetted at. This makes these classes > > > useless except to the authors. > > IIRC, nobody can ever answer this question. It may be a theoretical risk, or > > a real one. Who knows? > > Dunno. Hopefully someone on the project has a clue?
The Fast* classes provide a thread-safe wrapper around collection classes. Their read operations are faster than the thos of the sychronizing wrappers in the standard Java libraries. However, the write operations are slower. This is because all state is stored in a single field. Read operations can access this state without synchronization. Only write operations are synchronized. The write operations update the state by copying it, updating the copy, then replacing the original state with the copy. The copy operation is atomic, so the classes are thread safe. However on some platforms they may not behave as expected. As the JVM spec is written, read operations in different threads may not notice when the state is changed. This is because different threads are permitted to give different values for non-volatile fields in unsynchronized code. The read operations aren't synchronized and the field insn't volatile so the read operations may not operate on the latest state. I don't think this happens much in practice because most JVM implementations always show the same value, even in different threads. However, the possibility exists that the Fast* classes won't work as expected in some JVMs. I'm not very will connected to the net right now, so I haven't been able to verify this, but I think that may be what whoever wrote that note was talking about. Rich -- Rich Dougherty http://www.rd.gen.nz/ --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
