On Wed, Sep 26, 2012 at 5:23 PM, Maciej Liżewski
<maciej.lizew...@gmail.com> wrote:
> in Java (for example) you just write class:
> class Counter {
>   static private counter = 0;
>
>   public void increment() {
>     this.counter++;
>   }
> }
>

And here's where things go wrong.. You assume ++ is an atomic
operation, but in Java that's not true for static variables (it is for
local, but what does it matter?)
So you might end up with a race condition here where the counter will
only be incremented once when there are two or more threads. You need
a mutex or semaphore to make sure there's only one thread
reading/writing the counter at the same time (though volatile would
work here too probably).

Writing scripts for an application server requires a much deeper
understanding of threads and computer internals,so as a result it
probably increases error rate.

I think Alessandro explained the rest of the downsides pretty clearly.

- Matijn

Ps. Please bottom-post on this mailing list

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to