On Mar 2, 2007, at 1:15 PM, [EMAIL PROTECTED] wrote:

> Charles, I don't understand your thread-safety example.  You say that
> this one:
>
> Sub Example()
>  for i as Integer = 0 to 19
>    static foo as Integer
>  next
> End Sub
>
> ..could cause unpredictable results, but this one is fine:
>
> Sub Example()
>  static foo as Integer
>  for i as Integer = 0 to 19
>    //code
>  next
> End Sub
>
> As far as I know, the only difference between these examples is  
> that in
> the first one, the static variable can only be accessed within the
> loop, while in the second one, it can be accessed anywhere in the
> method.  There is no difference in thread safety that I can see.  Can
> you explain what you're getting at here?

Maybe not.  Now that I think about it, neither example is  
particularly thread-safe.  In either example, foo can be changed by  
one thread while another yields during the loop.  Some revision may  
be in order.


------------------------
Charles Yeomans
http://www.declareSub.com/


_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives:
<http://support.realsoftware.com/listarchives/lists.html>

Reply via email to