Package io.javago.sync
Class Once
java.lang.Object
io.javago.sync.Once
The
Once
class implements Go's sync.Once
.
A utility class that ensures a given Runnable
is executed only once.-
Constructor Summary
Constructors -
Method Summary
-
Constructor Details
-
Once
public Once()Constructs a newOnce
instance.
-
-
Method Details
-
doOnce
Executes the specifiedRunnable
only once. If theRunnable
has already been executed, subsequent calls will block until the first execution is complete.- Parameters:
func
- theRunnable
to be executed once
-