java-memory-model Questions
3
The following code sample shows a common way to demonstrate concurrency issues caused by a missing happens-before relationship.
private static /*volatile*/ boolean running = true;
public static v...
Janik asked 22/7, 2022 at 12:30
4
When a synchronized method is completed, will it push only the data modified by it to main memory, or all the member variables, similarly when a synchronized method executes, will it read only the ...
Aerodonetics asked 31/7, 2012 at 5:27
4
Solved
I have some question regarding program order and how it affects reorderings in the JMM.
In the Java Memory Model, program order (po) is defined as the total order of actions in each thread in a pro...
Valentin asked 10/9, 2015 at 3:25
1
The memory model is defined in 17.4. Memory Model.
The final field multi-threading guarantees are given in 17.5. final Field Semantics.
I don't understand why these are separate sections.
AFAIK bot...
Kaiserism asked 31/7, 2022 at 23:9
6
We use volatile in one of our projects to maintain the same copy of variable accessed by different threads. My question is whether it is alright to use volatile with static. The compiler does not g...
Christianize asked 3/2, 2011 at 11:31
4
Solved
Many programming languages today have happens-before relation and release+acquire synchronization operations.
Some of these programming languages:
C/C++11: happens-before, release+acquire
Rust and...
Haughay asked 1/11, 2021 at 1:38
5
Solved
Here:
An object is considered to be completely initialized when its constructor finishes. A thread that can only see a reference to an object after that object has been completely initialized is g...
Ewing asked 19/10, 2021 at 22:25
3
Solved
Lets save I have this code which exhibits stale cache reads by a thread, which prevent it from exiting its while loop.
class MyRunnable implements Runnable {
boolean keepGoing = true; // volatile ...
Laborious asked 13/9, 2021 at 21:29
3
Solved
Is the following code thread-safe? If so, what guarantees the safe publication of the ByteBuffer instance to the thread executing the CompletionHandler?
AsynchronousSocketChannel channel = ...
Byte...
Hebephrenia asked 26/8, 2021 at 9:32
1
Solved
Recently in a conference talk the following was used as an example to demonstrate the Java memory model in a multithreaded environment.
public class A {
public static boolean done;
public stati...
Inimical asked 3/4, 2021 at 17:37
2
Solved
This question came to me after reading this answer.
Code example:
class Obj1 {
int f1 = 0;
}
volatile Obj1 v1;
Obj1 v2;
Thread 1 | Thread 2 | Thread 3
-------------------------------------------...
Liddle asked 15/2, 2021 at 19:16
2
Solved
In my case, I want to implement the Acquire/Release model in java8 with volatile.
So I write the code that uses a volatile shared variable I to guarantee the modifying of MAP could be seen by other...
Phenanthrene asked 29/1, 2021 at 9:23
4
Solved
I'm currently trying to understand this JLS section on final fields.
To understand the text in the JLS better I'm also reading The Java Memory Model by Jeremy Manson (one of creators of the JMM).
T...
Sural asked 28/1, 2021 at 0:19
2
Solved
I'm learning the JDK9 memory model.
After watching the speech
Java Memory Model Unlearning Experience
and reading the paper
Using JDK 9 Memory Order Modes.
I'm confused about some concepts.
Does o...
Rizas asked 26/1, 2021 at 6:36
2
Solved
I'm reading Chapter 17. Threads and Locks of JLS and the following statement about sequential consistency in Java seems incorrect to me:
If a program has no data races, then all executions of the ...
Rich asked 1/1, 2021 at 4:12
3
Solved
I am watching video from java jpoint conference.
I have question about following slide from Alexey Shipilev report:
Excuse me for non-english on slide. Actually author says that it is impossibl...
Tellurate asked 23/10, 2017 at 12:37
4
Solved
Does Java allows output 1, 0? I've tested it very intensively and I cannot get that output. I get only 1, 1 or 0, 0 or 0, 1.
public class Main {
private int x;
private volatile int g;
// Execu...
Melburn asked 16/7, 2017 at 22:29
4
Solved
Consider this example. We're having:
int var = 0;
Thread A:
System.out.println(var);
System.out.println(var);
Thread B:
var = 1;
The threads run concurrently. Is the following output possi...
Justly asked 24/11, 2020 at 9:25
9
Solved
Can anyone tell me whether this class is threadsafe or not ?
class Foo {
private final Map<String,String> aMap;
public Foo() {
aMap = new HashMap<String, String>();
aMap.put("1",...
Seltzer asked 23/6, 2011 at 16:1
4
Solved
I've taken a look into OpenJDK source code of CopyOnWriteArrayList and it seems that all write operations are protected by the same lock and read operations are not protected at all. As I understan...
Deputation asked 1/6, 2010 at 15:1
2
Solved
Could you explain in simple words what "the program satisfies intra-thread semantic" means? Is it possible to provide simple examples of programs which satisfy and which don't satisfy such semantic...
Weidner asked 7/9, 2014 at 14:6
4
I'm reading a book "Java concurrency in practice" by Brian Goetz. Paragraphs 3.5 and 3.5.1 contains statements that I can not understand.
Consider the following code:
public class Holder ...
Colicweed asked 2/6, 2018 at 10:18
2
Solved
Recently I was reading the page The JSR-133 Cookbook for Compiler Writers by Doug Lea regarding JSR 133: JavaTM Memory Model and Thread Specification Revision.
There I read this line:
Memory barri...
Shocking asked 12/7, 2020 at 2:35
2
Solved
Below code sample is taken from JLS 17.5 "final Field Semantics":
class FinalFieldExample {
final int x;
int y;
static FinalFieldExample f;
public FinalFieldExample() {
x = 3;
y = 4;
}...
Loveridge asked 9/6, 2020 at 8:55
2
Solved
I am trying to understand the intrinsics of java volatile and its semantics, and its transaltion to the underlying architecture and its instructions. If we consider the following blogs and resourse...
Merridie asked 27/4, 2017 at 21:31
1 Next >
© 2022 - 2025 — McMap. All rights reserved.