MASON-INTEREST-L Archives

October 2007

MASON-INTEREST-L@LISTSERV.GMU.EDU

Options: Use Monospaced Font
Show Text Part by Default
Show All Mail Headers

Message: [<< First] [< Prev] [Next >] [Last >>]
Topic: [<< First] [< Prev] [Next >] [Last >>]
Author: [<< First] [< Prev] [Next >] [Last >>]

Print Reply
Subject:
From:
Sean Luke <[log in to unmask]>
Reply To:
MASON Multiagent Simulation Toolkit <[log in to unmask]>
Date:
Thu, 25 Oct 2007 19:51:33 -0400
Content-Type:
text/plain
Parts/Attachments:
text/plain (31 lines)
When you schedule something, the schedule (or the SimState's mini- 
schedule) holds onto that object until its event time has come up.   
Sometimes this isn't desirable.  For example, imagine if you wanted  
to schedule a window to be updated at a certain time, but someone  
might close the window before this time occurrs and you need to have  
the resources released.  You can do this by wrapping the steppable in  
a WeakSteppable, schedule the WeakSteppable, and then store the  
steppable in some instance variable in the window.  If the window is  
closed, the only thing left pointing to the window is the steppable.   
And the only things left pointing to the steppable are the window and  
the WeakSteppable holding the steppaable.  Since the WeakSteppable's  
reference to the steppable is weak, this means that the window and  
the steppable are the only things *really* left pointing to each  
other.  Which means they're candidates for garbage collection.

When they get garbage collected, the WeakSteppable's reference  
magically becomes null.  When the schedule later calls the  
WeakSteppable, nothing happens (because there's no window left).

This relies on the notion of Weak References, a concept introduced in  
Java 1.3 which you may want to read up on a bit for more info.

Sean

On Oct 25, 2007, at 7:34 PM, Alan Thomas wrote:

> I read about "schedule weakly," but I`m still not completely sure I
> understand it.  Could someone explain it?
>
> Thanks, Alan

ATOM RSS1 RSS2