On Sat, Apr 11, 2009 at 5:15 AM, Dean S. Jones <[email protected]> wrote:
>
> My assumption is, Async.RPC, like any static in a class, is not
> initialized till the class is first referenced. The "Internal Class"
> trick you cite
> has more to do with "Java Proper" Classloaders, and how they handle
> initialization in a Multi-threaded environment ( they are guaranteed
> to
> be determinate and atomic )
Well, not quite exactly, right? Cause the idea is you want to lazy load the
singleton. If you just assign it to a static variable, then it'll get
eagerly loaded when the class is first referenced. The internal class isn't
for the thread-safety part because assigning it without the internal class
is also thread safe (static variables are always initialized
thread-safely). It's strictly for the lazy loading to be thread-safe (not
having to write explicit synchronization code & also the JIT actually swaps
out the synchronization once it is safe).
I'm not 100%, but it's likely that the Async class will get loaded on
startup. You can always verify when it happens by doing a
static {
GWT.log('loading rpc", null);
}
to verify when this happens.
>
>
> But at this time, JavaScript is single threaded, so my idiom seems
> safe.
>
>
> for now ;-)
>
> >
>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Google Web Toolkit" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/Google-Web-Toolkit?hl=en
-~----------~----~----~----~------~----~------~--~---