#include "array.h"
#include <iostream>
#include <thread>
#include <vector>


template <int N, typename T>
void incr( threadsafe_array< N, T > & a, T val )
{
    for ( int i=0; i<N; ++i ) {
        a.Set( i, val );
    }
}

int main() 
{
    threadsafe_array< 100, int > a;

    std::vector<std::thread> threads;
    for( unsigned i=0; i<2; ++i ) {
        threads.push_back( std::thread( incr<100,int>, std::ref( a ), i ) );
    }
    for( auto & t : threads ) {
        t.join();
    }

    for ( int i=0; i<100; ++i ) {
        std::cout << a.Get( i );
    }
    std::cout << std::endl;
}