v / vlib / sync
Raw file | 22 loc (20 sloc) | 485 bytes | Latest commit hash 017ace6ea
1import sync
2
3fn simple_thread() u64 {
4 tid := sync.thread_id()
5 eprintln('simple_thread thread_id: ${tid.hex()}')
6 return tid
7}
8
9fn test_sync_thread_id() {
10 mtid := sync.thread_id()
11 eprintln('main thread_id: ${sync.thread_id().hex()}')
12 x := spawn simple_thread()
13 y := spawn simple_thread()
14 xtid := x.wait()
15 ytid := y.wait()
16 eprintln('main thread_id: ${sync.thread_id().hex()}')
17 dump(xtid.hex())
18 dump(ytid.hex())
19 assert mtid != xtid
20 assert mtid != ytid
21 assert xtid != ytid
22}