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]

Reply via email to