Thread.CurrentThread - How can it return object instance when it is static

Hello Friends,

In my casual reading, I came across that Thread.CurrentThread returns the current thread instance and this is a static read-only property. I don't understand it's implementation. If this is static, then how can it return object's instance? How would the property definition be written (there is no "this" here... right???) ?

I am sure I am missing something here... Please let me know ur suggestions...

Thanks
srinivas_vemlaAsked:
Who is Participating?
 
gregoryyoungCommented:
It is stored by the CLR as they are logical threads not OS level threads in reality (it actually does some mapping internally) ...

to see the table for OS level threads ...

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemdiagnosticsprocessclassthreadstopic.asp

Greg
0
 
gregoryyoungCommented:
public class foo() {
    public static foo CurrentFoo {
         return new foo(); //naturally it would be looking up the existant thread in a table but ...
    }
}


does this not return an instance of a foo from a static property?



0
 
srinivas_vemlaAuthor Commented:
Yeah, it does return an instance... but does it return the "current" instance.... u know, how does the called function know who is calling, when it is static? I am confused on that point...
0
Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
gregoryyoungCommented:
there is a static table out there that holds the threads ... it is using an OS call to get your thread object then returning it to you ...

0
 
srinivas_vemlaAuthor Commented:
tx greg for your replies... I guess that answers my question... do u have any link that wud describe the static tables? that wud be great...
0
 
srinivas_vemlaAuthor Commented:
Thanks Greg,

thanks for the info...
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.