import tables, locks, threadpool var hlock: Lock var chats {.guard: hlock.}: Table[int64, int64] template lock(a: Lock; body: stmt): auto = a.acquire defer: a.release {.locks: [a].}: body proc test() = lock hlock: chats[1] = 2 proc main() = lock hlock: chats = initTable[int64, int64]() spawn test() main()