The code defines a variable called data. Your task is to track changes in the value of the variable. Of course, for this task, an infinite loop will be necessary. But to reduce the load on the processor, use a ticker. The ultimate goal can be formulated as follows: it is necessary to check the value of the variable data at intervals of 200 milliseconds, and when its value changes, pass the number of iterations passed to the function check() and terminate the program.
Synchronization with channels
200 ms problem
Report a typo
Write a program in Go
package main
import (
"fmt"
"time"
)
func main() {
// DO NOT delete or modify the lines below, they are used in the code
var data int
generator(&data)
interval := 200
tick := time.Duration(interval) * time.Millisecond
sync := ?
var ?, loopsCount int
for {
loopsCount++
// provide your solution here
}
// DO NOT delete or modify the lines below, they are used for checking the answer
fmt.Println("done")
check(loopsCount)
}
___
By continuing, you agree to the JetBrains Academy Terms of Service as well as Hyperskill Terms of Service and Privacy Policy.
Create a free account to access the full topic
By continuing, you agree to the JetBrains Academy Terms of Service as well as Hyperskill Terms of Service and Privacy Policy.