AtomicBoolean get() method in Java with Examples
Last Updated :
27 Feb, 2019
The java.util.concurrent.atomic.AtomicBoolean.get() is an inbuilt method in java which returns the current value which is of date-type boolean.
Syntax:
public final boolean get()
Parameters: The function does not accepts any parameter.
Return Value: The function returns the current value
Below programs illustrate the above function:
Program 1:
import java.util.concurrent.atomic.AtomicBoolean;
public class GFG {
public static void main(String args[])
{
AtomicBoolean val
= new AtomicBoolean( false );
boolean res = val.get();
System.out.println( "current value: "
+ res);
}
}
|
Output:
current value: false
Program 2:
import java.util.concurrent.atomic.AtomicBoolean;
public class GFG {
public static void main(String args[])
{
AtomicBoolean val = new AtomicBoolean( true );
boolean res = val.get();
System.out.println( "current value: "
+ res);
}
}
|
Output:
current value: true
Reference: https://docs.oracle.com/javase/8/docs/api/java/util/concurrent/atomic/AtomicBoolean.html#get–
Like Article
Suggest improvement
Share your thoughts in the comments
Please Login to comment...