Duplicate Actors Share BeginPlay Logic Using Async

Legend, thank you! I wasn’t thinking thread safety here since each duplicated object should have encapsulated logic. Each object, each new thread, each new call to RandRange. I wasn’t even looking in the underlying logic of Rand. Seriously appreciate it!

In case someone in the future wants to see the solution.

void ACPP_ThreadActor::PrintSomething(FString ActorName, int RandomTime)
{
	while(bAsyncRunning)
	{
		FPlatformProcess::Sleep(RandomTime);
		UE_LOG(LogTemp, Warning, TEXT("[%s]Printing STUFF! [%i]"), *ActorName, RandomTime);
	}
}

// Called when the game starts or when spawned
void ACPP_ThreadActor::BeginPlay()
{
	Super::BeginPlay();

	FRandomStream* RandomTime = new FRandomStream(NAME_None);
	
	auto Result = Async(EAsyncExecution::Thread, [this, RandomTime]()
	{
		PrintSomething(GetName(), RandomTime->RandRange(1,5));
	});
}