Example of a simple script creating 3 threads.
void *handle(void *ptr)
{
int upd = 50000;
sprintf(
name,
"hpx%ld",nr);
hpx[nr] =
new TH1F(
name,
"This is the px distribution",100,-4,4);
for (
Int_t i = 0; i < nfills; i++) {
pz = px*px + py*py;
if (i && (i%upd) == 0) {
if (i == upd) {
}
if (
c[nr])
c[nr]->Modified();
}
}
return 0;
}
void *joiner(void *)
{
return 0;
}
{
}
void threadsh1()
{
c[0] =
new TCanvas(
"c0",
"Dynamic Filling Example",100,20,400,300);
c[0]->GetFrame()->SetFillColor(21);
c[0]->GetFrame()->SetBorderSize(6);
c[0]->GetFrame()->SetBorderMode(-1);
c[1] =
new TCanvas(
"c1",
"Dynamic Filling Example",510,20,400,300);
c[1]->GetFrame()->SetFillColor(21);
c[1]->GetFrame()->SetBorderSize(6);
c[1]->GetFrame()->SetBorderMode(-1);
c[2] =
new TCanvas(
"c2",
"Dynamic Filling Example",100,350,400,300);
c[2]->GetFrame()->SetFillColor(21);
c[2]->GetFrame()->SetBorderSize(6);
c[2]->GetFrame()->SetBorderMode(-1);
c[3] =
new TCanvas(
"c3",
"Dynamic Filling Example",510,350,400,300);
c[3]->GetFrame()->SetFillColor(21);
c[3]->GetFrame()->SetBorderSize(6);
c[3]->GetFrame()->SetBorderMode(-1);
c[0]->Connect(
"Closed()", 0, 0,
"closed(Int_t=0)");
c[1]->Connect(
"Closed()", 0, 0,
"closed(Int_t=1)");
c[2]->Connect(
"Closed()", 0, 0,
"closed(Int_t=2)");
c[3]->Connect(
"Closed()", 0, 0,
"closed(Int_t=3)");
printf("Starting Thread 0\n");
t[0] =
new TThread(
"t0", handle, (
void*) 0);
printf("Starting Thread 1\n");
t[1] =
new TThread(
"t1", handle, (
void*) 1);
printf("Starting Thread 2\n");
t[2] =
new TThread(
"t2", handle, (
void*) 2);
printf("Starting Thread 3\n");
t[3] =
new TThread(
"t3", handle, (
void*) 3);
printf("Starting Thread 4\n");
t[4] =
new TThread(
"t4", joiner, (
void*) 3);
while (!finished) {
for (int i = 0; i < 4; i++) {
if (
c[i] &&
c[i]->IsModified()) {
}
}
}
delete t[0];
delete t[1];
delete t[2];
delete t[3];
delete t[4];
delete rng[0];
delete rng[1];
delete rng[2];
delete rng[3];
}
R__EXTERN TSystem * gSystem
virtual void SetFillColor(Color_t fcolor)
Set the fill area color.
1-D histogram with a float per channel (see TH1 documentation)}
virtual Int_t Fill(Double_t x)
Increment bin with abscissa X by 1.
virtual void Draw(Option_t *option="")
Draw this histogram with options.
Random number generator class based on M.
This is the base class for the ROOT Random number generators.
virtual void SetSeed(ULong_t seed=0)
Set the random generator seed.
virtual void Rannor(Float_t &a, Float_t &b)
Return 2 numbers distributed following a gaussian with mean=0 and sigma=1.
virtual void Sleep(UInt_t milliSec)
Sleep milliSec milli seconds.
virtual Bool_t ProcessEvents()
Process pending events (GUI, timers, sockets).
static void Ps()
Static method listing the existing threads.
static Int_t UnLock()
Static method to unlock the main thread mutex.
Int_t Kill()
Kill this thread.
Long_t Join(void **ret=nullptr)
Join this thread.
Int_t Run(void *arg=nullptr, const int affinity=-1)
Start the thread.
static Int_t Lock()
Static method to lock the main thread mutex.