Advertisement
Guest User

Untitled

a guest
Dec 2nd, 2019
204
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import { main, worker, spawn, marshal } from 'recursive-worker'
  2.  
  3. @marshal() class Program {
  4.  
  5.     run() {
  6.        
  7.         console.log('hello world')
  8.      }
  9. }
  10.  
  11. @worker() class Thread {
  12.  
  13.     run(program: Program) {
  14.  
  15.         program.run()
  16.     }
  17. }
  18.  
  19.  
  20. main(async () => {
  21.  
  22.     const thread = spawn(Thread)
  23.  
  24.     await thread.run(new Program())
  25.  
  26.     await thread.dispose()
  27. })
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement