-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_list.go
More file actions
46 lines (40 loc) · 740 Bytes
/
test_list.go
File metadata and controls
46 lines (40 loc) · 740 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
package main
import (
"container/list"
"fmt"
"sync"
"time"
)
//func main() {
// //list := list.List{}
// //list.PushFront(11)
// //go printInfo1(&list)
// //
// //time.Sleep(time.Duration(3)*time.Second)
// //list.PushFront(222)
// //
// //time.Sleep(time.Duration(1000)*time.Second)
//
// list := list.List{}
// list.PushFront(22)
// list.PushFront(2233)
//
// for e := list.Front(); e != nil; e = e.Next() {
// fmt.Println(e.Value)
// }
//}
func printInfo1(list *list.List) {
mu := sync.Mutex{}
for true {
mu.Lock()
fmt.Println(list.Len())
ele := list.Front()
if ele != nil {
fmt.Println(ele.Value)
list.Remove(ele)
fmt.Println(list.Len())
}
time.Sleep(time.Duration(6) * time.Second)
mu.Unlock()
}
}