Carl Franklin

.NET Wonk

SyncLock Demo

I had been fumbling with a good demo for thread synchronization for a while and finally came up with a good demo in VB.NET 2003 illustrating the value of thread synchronization. It calls a sub on three different threads simultaneously. The sub increments a counter in a for/next loop. There are two versions, a raw unsynchronized version and a version that calls SyncLock to synchronize access to the counter.

http://www.franklins.net/dotnet

Comments

Marshall Brooke said:

Carl,

There is also the Interlocked.Increment method which takes a reference to an Int32/64 variable and atomically adds 1 to it. I'm not sure about the performance implications over Synclock/lock, but it may perform better for just incrementing an int.

best

Marshall
# August 22, 2004 9:30 AM

Carl said:

Yes indeed. Good point. It's hard to come up with a good synclock demo that doesn't generate a lot of data
# August 22, 2004 10:36 AM

Monster beats studio said:

Do you have a spam problem on this site; I also am a blogger, and I was wanting to know your situation; many of us have created some nice practices and we are looking to swap solutions with others, be sure to shoot me an email if interested.

# July 18, 2011 6:25 AM

baseball caps said:

the style we mainly found was Stencil Graffiti Art as well plenty of Murals and other similar intensive artworks. Not just text and type.

# July 19, 2011 9:11 PM

cheap gucci bags said:

you mean you don’t need a special tool? That’s refreshing! Thanks!

# July 24, 2011 8:29 PM

cheap north face jackets said:

Thanks for getting the time to discuss this, I really feel strongly about this and love learning more on this topic.<a href="www.cheapnorthfaceoutlets.com/" title="cheap north face jackets">cheap north face jackets</a>

# August 4, 2011 3:18 AM

fashion bags said:

I am happy to have found this blog, and more happy to have long tail explained so well. Thanks.<a href="www.fashion-bags-store.com/" title="fashion bags">fashion bags</a>

# August 5, 2011 10:41 PM

Louis Vuitton outlet said:

Always worth visiting your blog to read your cool posts. Keep them coming.

# August 11, 2011 9:06 PM

Moncler sale said:

This is easier and surely gives comfort to us. Thanks for sharing. I really enjoy the information.keep up the good work.

# August 12, 2011 9:33 PM

Cheap Timberland Boots said:

This is a really good read for me, Must admit that you are one of the best bloggers I ever saw.Thanks for posting this informative article.<a href="www.cheap-timberlandbootsoutlet.com/" title="Cheap Timberland Boots">Cheap Timberland Boots</a>

# August 12, 2011 9:53 PM

Wholesale Caps said:

Interesting posts here.. gracias for sharing so much in your blog.. Greets.

# August 13, 2011 4:48 AM

cheap handbags outlet said:

i'm happy to see this post because i made of the best actress that i can be proud of it.<a href="http://www.sacing.com/" title="cheap handbags outlet">cheap handbags outlet</a>

# August 17, 2011 5:37 AM

supra tk society said:

Your site has helped me a lot to bring back more confidence in myself. Thanks! Ive recommended it to my friends as well.[url=www.supratksocietysale.com]supra tk society[/url]

# August 18, 2011 8:15 PM

rtyecript said:

I really liked the article, and the very cool blog

# August 23, 2011 8:54 AM

aOaMtNoK said:

# October 19, 2011 9:56 PM
Leave a Comment

(required) 

(required) 

(optional)

(required)