Here's a list of different methods:
- setting the specified
longvalue to a long field (withoutvolatile)
public void setLong(long val) {
this.val = val;
}
- setting the specified
intvalue to anintfield (withoutvolatile)
public void setInt(int val) {
this.val = val;
}
- increment the
intfield by n
public void incrementBy(int n) {
this.field += n;
}
- setting the specified
intvalue to anintfield (withoutvolatile) and increment the field by one
public void setAndInc(int val) {
this.val = val;
this.val++;
}
- setting the specified
longvalue to alongfield (withvolatile)
public void setLongVolatile(long val) {
this.val = val;
}
Select all the methods that represent atomic operations. It means that when a thread changes a value, other threads will not be able to access any intermediate values. They should only read a value as it was before an invocation of the method and after the method has completed its work.