| 1 | import sync |
| 2 | |
| 3 | fn simple_thread() u64 { |
| 4 | tid := sync.thread_id() |
| 5 | eprintln('simple_thread thread_id: ${tid.hex()}') |
| 6 | return tid |
| 7 | } |
| 8 | |
| 9 | fn 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 | } |
| 23 | |