mirror of
https://github.com/nim-lang/Nim.git
synced 2026-01-01 10:52:14 +00:00
23 lines
366 B
Nim
23 lines
366 B
Nim
discard """
|
|
output: '''some string here'''
|
|
"""
|
|
|
|
var
|
|
someGlobal: string = "some string here"
|
|
perThread {.threadvar.}: string
|
|
|
|
proc setPerThread() =
|
|
{.gcsafe.}:
|
|
deepCopy(perThread, someGlobal)
|
|
|
|
proc foo() {.thread.} =
|
|
echo perThread
|
|
|
|
proc main =
|
|
onThreadCreation setPerThread
|
|
var t: Thread[void]
|
|
createThread[void](t, foo)
|
|
t.joinThread()
|
|
|
|
main()
|