{"size": 618, "ext": "js", "max_stars_repo_path": "examples/thread/timers.js", "max_stars_repo_name": "stealify/stealify", "max_stars_repo_stars_event_min_datetime": "2018-10-28T07:59:04.000Z", "max_stars_repo_stars_event_max_datetime": "2021-02-14T20:50:14.000Z", "max_issues_repo_path": "examples/thread/timers.js", "max_issues_repo_name": "stealify/stealify", "max_issues_repo_issues_event_min_datetime": "2017-11-05T23:34:05.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-08T08:42:06.000Z", "max_forks_repo_path": "examples/thread/timers.js", "max_forks_repo_name": "stealify/stealify", "max_forks_repo_forks_event_min_datetime": "2020-01-12T00:38:37.000Z", "max_forks_repo_forks_event_max_datetime": "2020-01-12T00:38:37.000Z"}
{"max_stars_count": 5, "max_issues_count": 123, "max_forks_count": 1, "avg_line_length": 24.72, "max_line_length": 80, "alphanum_fraction": 0.6812297735}
stealify.thread = stealify.library('thread', 'thread.so').thread

function threadOne () {
  stealify.setInterval(() => {
    stealify.print('hello from thread one')
  }, 1000)
}

function threadTwo () {
  stealify.setInterval(() => {
    stealify.print('hello from thread two')
  }, 1000)
}

function spawn (fn) {
  let source = fn.toString()
  source = source.slice(source.indexOf('{') + 1, source.lastIndexOf('}')).trim()
  return stealify.thread.spawn(source, stealify.builtin('stealify.js'))
}

const tids = []
tids.push(spawn(threadOne))
tids.push(spawn(threadTwo))
tids.forEach(tid => stealify.thread.join(tid))
