Saturday, May 31, 2008

Now! That has to be one of my greatest findings! Ever!

The Indexer method (the one that allows for doing object[something]) of the Hashtable class in .NET has a Thread.Sleep(1) inside one of the loops!!!!

Yes I repeat Thread.Sleep(1)!

Why would anyone want to insert a Thread.Sleep() call in to a Hashtable, or any other BCL class for that matter, is beyond me.

Can you beat this gem?

Sunday, June 01, 2008 7:03:02 AM (Central European Standard Time, UTC+01:00)
It's called "playing nice with others." You deliberately yield CPU ownership with Thread.Sleep(1) to allow another thread a chance to execute.

In this case, the get_Item code is giving another thread with write access to the hashtable an chance to finish. This way, the get method can check its hashtable bucket again after the write's done in case it changed because of the write.

Without Thread.Sleep(1) out, get_Item would waste a lot of CPU cycles constantly checking a bucket that isn't being given a chance to update, because we're hogging the CPU busy-waiting for it to finish.
Joe Chung
Sunday, June 01, 2008 10:14:17 AM (Central European Standard Time, UTC+01:00)
Since when do a BCL class code implicitly "plays nice with others"?

I mean, I understand the concept, but! No way I could accept such an explainationos.

Is there any other class that impplicitly does this?
Dictionary<TKey, TValue> maybe? Nope. List<T>? Nope.

Reason is: if you want your code to behave nicely in multi-threaded environement - code it yourself.
Monday, June 02, 2008 7:57:39 AM (Central European Standard Time, UTC+01:00)
there is a nice post of Joe Duffy (http://www.bluebytesoftware.com/blog/PermaLink,guid,1c013d42-c983-4102-9233-ca54b8f3d1a1.aspx) regarding Thread.Sleep(1)
Monday, October 19, 2009 5:37:19 AM (Central European Standard Time, UTC+01:00)
Hi guys. Never part without loving words to think of during your absence. It may be that you will not meet again in life.
I am from Thailand and also now teach English, give please true I wrote the following sentence: "Quickly, in some limits, one can very use their young practitioner for a market."

With best wishes :), Vanora.
Sunday, December 06, 2009 5:50:25 PM (Central European Standard Time, UTC+01:00)
Sorry. Take a two-mile walk every morning before breakfast.
I am from Wales and also now teach English, give please true I wrote the following sentence: "Strattera, what is the possible brain that has been known?"

Thanks for the help :(, Viola.
Tuesday, July 13, 2010 3:37:21 AM (Central European Standard Time, UTC+01:00)
Hello everybody, today really lucky
To introduce you these good online shops now!

Sale: GUCCI Bags, GUCCI Handbags, GUCCI Shoes, GUCCI Clothes, GUCCI Glasses, etc.
http://www.gucciboss.com/

2010 NFL, NFL Jerseys, NFL Jersey, NHL Jerseys, MLB Jerseys, NBA Jerseys, wholesale NFL Jerseys
http://www.2010-nfl.com/


Vibram,Five Fingers,fivefingers,Five Fingers Kso,Five Fingers Classic,Five Fingers Sprint,FiveFingers shoes,Vibram Outlet Sale
http://www.topfivefingers.com/

Christian Louboutin,Christian Louboutin shoes,Christian Louboutin sale,ChristianLouboutin Boots,Christian Louboutin Pumps,Christian Louboutin Sandals
http://www.superchristianlouboutin.com
Thursday, August 26, 2010 8:30:07 AM (Central European Standard Time, UTC+01:00)
http://www.gucciall.com
Discount Gucci, Discount Gucci Handbags, Gucci Sunglasses

http://www.wholesale-ugg-boots.com
UGG, UGG Boots, cheap UGG Boots

http://fivefingersshoes.tk
http://mychristianlouboutin.tk
http://ghdstraighteners.tk
http://kidsjerseys.tk
http://ghdshopping.tk
http://guccigucci.tk
http://saleshoes.tk
http://thehandbags.tk


http://ilikehandbags.tk
http://ilikejerseys.tk
http://isshoes.tk
http://rarehandbags.tk
http://rarejerseys.tk
http://rareshoes.tk
http://sellhandbags.tk
Name
E-mail
Home page

Comment (Some html is allowed: a@href@title, strike) where the @ means "attribute." For example, you can use <a href="" title=""> or <blockquote cite="Scott">.  

Enter the code shown (prevents robots):

Live Comment Preview