Example of a simple script creating 3 threads.
This script can only be executed via ACliC: .x threads.C++. Before executing the script, load the Thread library with:
R__EXTERN TSystem * gSystem
virtual int Load(const char *module, const char *entry="", Bool_t system=kFALSE)
Load a shared library.
This is not needed anymore due to the rootmap facility which automatically loads the needed libraries.
void *handle(void *ptr)
{
for (int i = 0; i < 10; i++) {
}
return 0;
}
void threads()
{
printf("Starting Thread 1\n");
printf("Starting Thread 2\n");
printf("Starting Thread 3\n");
}
virtual void Sleep(UInt_t milliSec)
Sleep milliSec milli seconds.
static void Ps()
Static method listing the existing threads.
Long_t Join(void **ret=nullptr)
Join this thread.
Int_t Run(void *arg=nullptr, const int affinity=-1)
Start the thread.
static void Printf(const char *fmt,...)
Static method providing a thread safe printf. Appends a newline.
- Author
- Victor Perevovchikov
Definition in file threads.C.