var data = cast[seq[string]](allocShared0(sizeof(seq[string])))
data.add("Test")
Run
You cannot do that, you are casting unmanaged memory, to GC-ed memory, this
will end with a crash in the GC. Though here you have a global variable so the
memory is never reclaimed.
Instead compile with `--gc:arc` or `--gc:orc` so that all threads can access
that sequence.
proc myThread(test : ptr seq[string]) {.thread.} =
echo "Start of new thread"
echo test[][0]
test[].add("I want to access this from the main thread!")
echo "End of new thread"
Run
Use locks to access shared memory