Using threads to just run a function once?

Hi,

I have a question that seems like the answer would be obvious but I can’t find out what it is.

I have three functions that I want to run, then exit the program. animation01(), animation02(), animation03().

However, this will loop them over and over forever:

void ofApp::draw() {
animation01();
animation02();
animation03();
}

What can I do to just go through these animations, and then end? Should I use threads for this purpose? In reading about threads it seems that this is intended for processor-intensive processes?

Thanks for any pointers! :slight_smile:

there are a few approaches but I think the most straightforward way would just to set a variable

bool a1 = false;
bool a2 = false;
bool a3 = false;

void ofApp::draw() {
	if(!a1)
	{
		animation1();
		a1 = true;
		return;
	}
	if(!a2)
	{
		animation2();
		a2 = true;
		return;
	}
	if(!a3)
	{
		animation3();
		a3 = true;
		ofExit();
	}
}