Select all atomic operations

Report a typo

Here's a list of different methods:

  • setting the specified long value to a long field (without volatile)
public void setLong(long val) {
    this.val = val;
}
  • setting the specified int value to an int field (without volatile)

public void setInt(int val) {
    this.val = val;
}
  • increment the int field by n

public void incrementBy(int n) {
    this.field += n;
}
  • setting the specified int value to an int field (without volatile) and increment the field by one
public void setAndInc(int val) {
    this.val = val;
    this.val++;
}
  • setting the specified long value to a long field (with volatile)
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.

Select one or more options from the list
___

Create a free account to access the full topic