mirror of
https://gitee.com/johng/gf.git
synced 2024-12-05 05:37:55 +08:00
18 lines
330 B
Go
18 lines
330 B
Go
package main
|
|
|
|
import (
|
|
"github.com/gogf/gf/g/os/gflock"
|
|
"github.com/gogf/gf/g/os/glog"
|
|
"github.com/gogf/gf/g/os/gproc"
|
|
"time"
|
|
)
|
|
|
|
func main() {
|
|
l := gflock.New("demo.lock")
|
|
l.Lock()
|
|
glog.Printfln("locked by pid: %d", gproc.Pid())
|
|
time.Sleep(3 * time.Second)
|
|
l.UnLock()
|
|
glog.Printfln("unlocked by pid: %d", gproc.Pid())
|
|
}
|