Hi FIlip, I actually made a test last night: http://moskito.anotheria.net/AtomicVsSynchronized.html
On suns jdk it seems to be faster, but not on jrockit. And synchronized on jrockit seems to be faster than atomic on sun on 1 processor machines. regards leon On 5/28/06, Filip Hanik - Dev Lists <[EMAIL PROTECTED]> wrote:
yes, compared to using synchronized, this is a huge improvement Leon Rosenberg wrote: > Hi, > > have someone made some actual measures on performance of atomiclong > compared to old-style synchronization? > Sun stats > (http://java.sun.com/developer/technicalArticles/J2SE/concurrency/) > that Atomics are faster than the synchronized() block, but from the > implementation of some methods I would actually see some data: > > /** > * Atomically increment by one the current value. > * @return the updated value > */ > public final long incrementAndGet() { > for (;;) { > long current = get(); > long next = current + 1; > if (compareAndSet(current, next)) > return next; > } > } > > as far as I understand calling this function from 3 threads > simulatenously would end in running through this block 6 times. 10 > Threads - 55 times. And so on. And this is still performant? > > regards > Leon > > --------------------------------------------------------------------- > To start a new topic, e-mail: users@tomcat.apache.org > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > > -- Filip Hanik --------------------------------------------------------------------- To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
--------------------------------------------------------------------- To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]