Fastest way to update an integer variable across threads

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I want to know what is the best design approach to update a variable across
threads.
 
Hello, BuddyWork!

B> I want to know what is the best design approach to update a variable
B> across
B> threads.

If you're talking about int variable then you can use Interlocked.Exchange(...)
to update variable value

--
Regards, Vadym Stetsyak
www: http://vadmyst.blogspot.com
 
Vadym Stetsyak said:
Hello, BuddyWork!

B> I want to know what is the best design approach to update a variable
B> across
B> threads.

If you're talking about int variable then you can use Interlocked.Exchange(...)
to update variable value

I do want to update a int variable. How reliable is Interlocked.Exchange, do
you have a simple example showing the variable updated across threads.

Thanks,
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top