Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Interlocked hanging game?

Just attempting to use Interlocked.Increment(ref threads) and it just hangs my game.

public static int threads;

...

Interlocked.Increment(ref threads);

Using System.Threads also.

I've moved it into the main thread and out of it, can't seem to get it to work anywhere. Is this just Unity causing this?

like image 426
Ken Rea Avatar asked Mar 13 '26 13:03

Ken Rea


1 Answers

The .Net Interlocked.Increment doesn't actually lock anything (at least it definitely doesn't for an int); it only ensures the increment happens atomically.

Either it is not actually the change causing your problem or you've got another Interlocked imported into your namespaces.

like image 109
Mark Hurd Avatar answered Mar 15 '26 01:03

Mark Hurd