instances v. threads

Robert Brewer fumanchu at amor.org
Fri Nov 19 18:55:28 EST 2004


Brad Tilley wrote:
> I've just started using classes in Python for some projects 
> at work and 
> have a few questions about them. I understand that once a class is 
> defined that I can create many instances of it like this:
> 
> class xyz:
>     def one():
>        pass
>     def two ():
>        pass
>     def three():
>        pass
> 
> a = xyz()
> b = xyz()
> c = xyz()
> 
> a.one()
> b.one()
> c.one()
> c.two()
> c.three()
> 
> How does asynchronous/threaded programming differ from OO programming 
> and classes? C is not OO and has no classes, but one can 
> write threaded 
> programs in C, right? Perhaps I'm totally off on this... can some 
> explain how these concepts differ? Exactly how is an 'instance' 
> different from a 'thread'?

A thread is a "thread of execution". An object instance is a chunk of
data on the heap. Any instance is available to any thread, if the thread
can obtain a reference to that instance.


Robert Brewer
MIS
Amor Ministries
fumanchu at amor.org



More information about the Python-list mailing list