DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

+ Reply to Thread
Results 1 to 4 of 4
  1. #1
    Sasha Gold Guest

    Threading differences between VS6 and .NET


    How is threading handled in .NET? In VS6 it was MTA, but how does this new
    system work?

  2. #2
    Rob Teixeira Guest

    Re: Threading differences between VS6 and .NET


    Actually, for the most part, VB6 used STA (which some people will probably
    argue is a special case of MTA in comparison with free threading). The point
    it that it's exceedingly difficult to provide general-purpose *safe* thread
    control for objects under COM, specially since the VB language didn't support
    any syntax for it to begin with. Therefore, the VB developers opted to make
    the objects work on one single thread and there you have it (of course there
    were some exceptions such as thread-pooled servers, but even then, the objects
    were created and remained in one single apartment of an MTA under the control
    of one single thread).

    VB.NET on the other hand is completely free threaded. If you want to run
    another thread, you simply create a new Thread object and specify the delegate
    (safe function pointer abstractions if you will) of the function you want
    the thread to start at (reminicent of Java-style threading).

    -Rob

    "Sasha Gold" <GoldS@hotmail.com> wrote:
    >
    >How is threading handled in .NET? In VS6 it was MTA, but how does this

    new
    >system work?



  3. #3
    Joe \Nuke Me Xemu\ Foster Guest

    Re: Threading differences between VS6 and .NET

    "Rob Teixeira" <RobTeixeira@@msn.com> wrote in message <news:3aa2f38a$1@news.devx.com>...

    > VB.NET on the other hand is completely free threaded. If you want to run
    > another thread, you simply create a new Thread object and specify the delegate
    > (safe function pointer abstractions if you will) of the function you want
    > the thread to start at (reminicent of Java-style threading).


    What sort of implicit mutex stuff does VB.NOT/the CLR do? By the time
    VB.NOT's made completely safe, it may as well be single-threaded.

    --
    Joe Foster <mailto:jfoster@ricochet.net> Get "Regged"! <http://www.xenu.net/>
    WARNING: I cannot be held responsible for the above They're coming to
    because my cats have apparently learned to type. take me away, ha ha!



  4. #4
    Rob Teixeira Guest

    Re: Threading differences between VS6 and .NET


    There are two primary safety issues with multiple threads:
    1)deadlock - when one thread is waiting for another thread to do something,
    but the other thread is also waiting on the first
    2)one thread modifies the value of a variable that a second thread is depending
    on while in the middle of executing a method

    There is a surprising number of thread safty mechanisms in place under .NET.
    The thread object itself can be suspended or aborted. In addition, it seems
    like even though the docs only mention free threading, appartment-style threading
    is also supported. When we used apartment style threading in VB6 it was easy
    because we didn't have to know anything, but the reality is that appartment
    style threading is more difficult to explain than free threading. I think
    that maybe the docs are still in the works in this area.
    You can also assign thread data slots, which I think is probably what the
    old Thread Local Storage used to do.
    In addition, there are also Mutex and Interlocked classes that act as synchronizers.
    And finally, VB.NET has a SyncLock statement that applies basic synchronization
    on a block.

    But before I leave, I'll say this:
    I think thread safety is a lot like circular references. They are dangerous
    because when thread bugs appear, they will kill the app and they are VERY
    hard to catch and debug.
    However, I think all the thread safety propaganda is over-hyped, just as
    the circular-reference hype was. I haven't seen a circular-reference problem
    in any application in the last two and half years.
    Sure, you need to be careful with multiple threads running, but if you design
    carefully, it's possible you may not need synchronization or locking at all.
    If anything, over-zelous use of locking will do nothing but slow your program
    down and make multiple threads useless.

    -Rob


    "Joe \"Nuke Me Xemu\" Foster" <joe@bftsi0.UUCP> wrote:
    >"Rob Teixeira" <RobTeixeira@@msn.com> wrote in message <news:3aa2f38a$1@news.devx.com>...
    >
    >> VB.NET on the other hand is completely free threaded. If you want to run
    >> another thread, you simply create a new Thread object and specify the

    delegate
    >> (safe function pointer abstractions if you will) of the function you want
    >> the thread to start at (reminicent of Java-style threading).

    >
    >What sort of implicit mutex stuff does VB.NOT/the CLR do? By the time
    >VB.NOT's made completely safe, it may as well be single-threaded.
    >
    >--
    >Joe Foster <mailto:jfoster@ricochet.net> Get "Regged"! <http://www.xenu.net/>
    >WARNING: I cannot be held responsible for the above They're coming

    to
    >because my cats have apparently learned to type. take me away,

    ha ha!
    >
    >



Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


Top DevX Stories

Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL


Sponsored Links