Reputation: 67
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?
Upvotes: 3
Views: 591
Reputation: 10931
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.
Upvotes: 1