import core.thread;
import std.c.stdio;

class foo {
 
  int a;
  shared int b;

  static int x;
  shared static int y;
  shared static int[] arr1;
  shared static int[] arr2;

  this() { a = 1; b=10; }
  static this() { x=100; arr1 ~= x; }
  shared static this() { y=1000; arr2 ~= y;  }

  static void A() { x++; y++; }
  void B() { a++; b++; }
  void report() {
    printf("a=%i; b=%i; x=%i; y=%i; arr1.length=%i; arr2.length=%i\n",a,b,x,y,arr1.length, arr2.length);
  }
}



void main() 
{

  auto f = new foo();
  void call_foo_functions() { f.A(); f.B(); f.report(); } 
  auto tg = new ThreadGroup();
  foreach (k; 0..3) {
    auto t = new Thread(&call_foo_functions);
    tg.add(t);
    t.start();
  }
  tg.joinAll();
  // a=1?
  // b=13?
  // x=100?
  // y=1003
  printf("back in main: ");
  f.report();
 } 
    



