concurrency

The volatile keyword in Java

Today I met this code class someClass { // ... private volatile int a; // ... } The question is, what is volatile in this context?

The concept of Fail-Fast iterators

Good time of day. If I understand correctly, Fail-Fast iterators immediately stop working (usually by generating exceptions) ... read until no one has changed anything" is preferred to the approach " I can only make changes until nobody reads anything"?

Java Atomic-are variables really atomic?

As you know, there are a number of Atomic shells for primitives. The main principle is that they do not use the usual synchro ... in current? Especially since value is declared as volatile, which means that this value is common to all potential threads.

Why is Java Concurrency in Practice code considered safe?

I am reading the book Java Concurrency in Practice and one example of "safe" code from Chapter 3 alerted me. The book says th ... null, hence the call to Arrays.copyOf(lastFactors, lastFactors.length) hello to NPA. Please correct me, where did I go wrong?

Waiting for the button to be pressed

How do I make the running method wait for the button to be clicked? yesButton.setOnClickListener(new View.OnClickListener() ... e() { @Override public void run() { jokeTextView.setText(R.string.joke_1_2); } }); }

Why is optimistic locking so named?

Why, for example, in java optimistic lock is called this way, and not otherwise?

Thread-safe ArrayList

I'm writing my implementation of a thread-safe error list on CAS-locks (don't ask why). I encountered some behavior that I di ... ments, this behavior also occurs, only much less often. I would be grateful if someone could tell me what's going on. Thanks.

CopyOnWriteArrayList vs ArrayList

I am studying the java.util.concurrent package. I reread a bunch of articles, but I can't understand the principle of thread ... es In some cases, we can use the thread-safe CopyOnWriteArrayList instead of synchronization. I would appreciate any example.