Here, we will loaded the value of 64-bit integer variable using atomic.LoadInt64() function. In the atomic.LoadInt64() function, we passed address of variables. The atomic.LoadInt64() function is used the values of variables in multithreaded/multi-process environment.
The source code to demonstrate the atomic.LoadInt64() function is given below. The given program is compiled and executed on the ubuntu 18.04 operating system successfully.
// Golang program to demonstrate the// atomic.LoadInt64() functionpackage main
import"fmt"import"sync/atomic"// Entry point for the programfuncmain(){var num1 int64=78612344444var num2 int64=11187432762
loadVal1 := atomic.LoadInt64(&num1)
loadVal2 := atomic.LoadInt64(&num2)//Print 64-bit integer loaded value
fmt.Println(loadVal1)
fmt.Println(loadVal2)}
Go
Output:
78612344444
11187432762
Explanation:
In the above program, we declare the package main. The main package is used to tell the Go language compiler that the package must be compiled and produced the executable file. Here, we imported the required packages to predefined functions.
In the main() function, we created two 64-bit integer variables num1, num2 that are initialized with 78612344444, 11187432762 respectively. Then we loaded the value of 64-bit integers using the atomic.LoadInt64() function. The atomic.LoadInt64() function is used the values of variables in multithreaded/multi-process environment. At last, we printed the loaded value of variables on the console screen.
Program/Source Code:
The source code to demonstrate the atomic.LoadInt64() function is given below. The given program is compiled and executed on the ubuntu 18.04 operating system successfully.
Output:
Explanation:
In the above program, we declare the package main. The main package is used to tell the Go language compiler that the package must be compiled and produced the executable file. Here, we imported the required packages to predefined functions.
In the main() function, we created two 64-bit integer variables num1, num2 that are initialized with 78612344444, 11187432762 respectively. Then we loaded the value of 64-bit integers using the atomic.LoadInt64() function. The atomic.LoadInt64() function is used the values of variables in multithreaded/multi-process environment. At last, we printed the loaded value of variables on the console screen.
need an explanation for this answer? contact us directly to get an explanation for this answer