safe-publication Questions
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
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
1
Solved
First off the code, from JCIP listing http://jcip.net/listings/StuffIntoPublic.java and
http://jcip.net/listings/Holder.java
public class SafePublication {
public static void main(String[] args) ...
Botheration asked 7/1, 2018 at 14:26
3
By reading Java Concurrency in Practice
I can see:
To publish an object safely, both the reference to the object and the object's state must be made visible to other threads at the same time. A p...
Athletics asked 18/10, 2016 at 21:59
3
Solved
I know that you can safely publish a non-thread safe object by writing the reference to a final or volatile field which will later be read by exactly one other thread, provided that upon publicatio...
Evanthe asked 7/7, 2016 at 17:43
3
Solved
Since StringBuffer is thread safe it can safely be published. Consider the public constructor of StringBuffer ( sources ):
public StringBuffer() {
super(16);
}
where super(16) designates this o...
Educable asked 6/4, 2016 at 9:58
6
Solved
After reading "Java concurrent in practice" and "OSGI in practice" I found a specific subject very interesting; Safe Publication. The following is from JCIP:
To publish a...
Agoraphobia asked 29/4, 2009 at 11:49
1
© 2022 - 2024 — McMap. All rights reserved.