Standard library / sync
sync.RWMutex.TryLock()
Attempt exclusive acquisition without blocking. Failure provides no synchronization. Expected stdout: 'false\n'.
Formal Syntax & Structure
go syntaxgo
func (rw *RWMutex) TryLock() boolReturn Value
bool
Whether write access was acquired.
Working Example
Example Snippetgo
package main
import ( "fmt" "sync")
func main() { var m sync.RWMutex; m.RLock(); fmt.Println(m.TryLock()); m.RUnlock() }