lc-go/solutions/11/q1114/solution.go
2026-01-29 10:14:39 +09:00

35 lines
468 B
Go

package q1114
type Foo struct {
one, two chan struct{}
}
func NewFoo() *Foo {
return &Foo{
one: make(chan struct{}),
two: make(chan struct{}),
}
}
func (f *Foo) First(printFirst func()) {
// Do not change this line
printFirst()
close(f.one)
}
func (f *Foo) Second(printSecond func()) {
<-f.one
/// Do not change this line
printSecond()
close(f.two)
}
func (f *Foo) Third(printThird func()) {
<-f.two
// Do not change this line
printThird()
}