Here's a list of different functions:
- setting a specified
Longvalue to aLongfield (without@Volatile)
fun setLong(value: Long) {
this.value = value
}
- setting a specified
Intvalue to anIntfield (without@Volatile)
fun setInt(value: Int) {
this.value = value
}
- increment the
Intfield by n (without@Volatile)
fun incrementBy(n: Int) {
this.field += n
}
- setting a specified
Intvalue to anIntfield (without@Volatile) and increment the field by one
fun setAndInc(value: Int) {
this.value = value
this.value++
}
- setting a specified
Longvalue to aLongfield (with@Volatile)
fun setLongVolatile(value: Long) {
this.value = value
}
Select all the functions 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 the value as it was before the invocation of the function and after the function has completed its work.