Listing 2: How to use the technique

#include "spawn.h"
#include <iostream>

using namespace std;

void foo(int i) {
  cout << " foo(" << i << ") called" << endl;
  // do something:
  for (int i=0; i<10000; ++i)  /*...*/;

  cout << "finished..." << endl;
};

int main () {
  Thread t = spawn(&foo)(1);

  cout << "joining..." << endl;  
  t.join ();

  cout << "done" << endl;  
};

— End of Listing —