t7172.nim 511 B

123456789101112131415161718192021222324252627282930313233
  1. discard """
  2. output: '''
  3. In doStuff()
  4. In initProcess()
  5. initProcess() done
  6. TEST
  7. Crashes before getting here!
  8. '''
  9. joinable: false
  10. """
  11. import std/os
  12. proc whatever() {.thread, nimcall.} =
  13. echo("TEST")
  14. proc initProcess(): void =
  15. echo("In initProcess()")
  16. var thread: Thread[void]
  17. createThread(thread, whatever)
  18. echo("initProcess() done")
  19. joinThread(thread)
  20. proc doStuff(): void =
  21. echo("In doStuff()")
  22. # ...
  23. initProcess()
  24. sleep(500)
  25. # ...
  26. echo("Crashes before getting here!")
  27. doStuff()