#include <base/Application.h>
#include <base/string/FormatOutputStream.h>
#include <base/concurrency/Thread.h>
#include <base/concurrency/ExclusiveSynchronize.h>
using namespace com::azure::dev::base;
private:
char value = 0;
unsigned int count = 0;
public:
MyThread(char _value, unsigned int _count)
: value(_value), count(_count)
{
}
void run()
{
{
fout << "Written by MyThread object" << ENDL;
}
while (count--) {
{
fout << value;
}
}
}
};
private:
static const unsigned int MAJOR_VERSION = 1;
static const unsigned int MINOR_VERSION = 0;
public:
ThreadApplication()
{
}
void main()
{
#if (_COM_AZURE_DEV__BASE__OS == _COM_AZURE_DEV__BASE__WASI) || \
(_COM_AZURE_DEV__BASE__ARCH == _COM_AZURE_DEV__BASE__SPARC64) // setup_rt_frame: not implemented
return;
#endif
fout << getFormalName() << " version "
<< MAJOR_VERSION << '.' << MINOR_VERSION << EOL
<< "The Base Framework (Test Suite)" << EOL
<< ENDL;
MyThread myThreadA('A', 4096);
MyThread myThreadB('B', 4096);
Thread myContextA(&myThreadA);
Thread myContextB(&myThreadB);
fout << "Starting threads..." << ENDL;
myContextA.start();
myContextB.start();
fout << "Waiting for threads to complete..." << ENDL;
myContextA.join();
myContextB.join();
}
};
APPLICATION_STUB(ThreadApplication);