Package org.javacord.core.util
Interface Cleanupable
-
- All Known Implementing Classes:
GroupChannelImpl
,MessageCacheImpl
,PrivateChannelImpl
,ServerImpl
,ServerTextChannelImpl
,UserImpl
public interface Cleanupable
This class represents an object which can clean up after itself. It should be used on objects that need to clean up references to itself that would prevent garbage collection or when it "owns" cleanupable objects. The most prominent example is, when thethread pool
is used to schedule a permanently repeated action on the object. This will prevent garbage collection as the scheduled task will have a hard reference to the instance and even if this is wrapped in aWeakReference
, if a lambda is used as task, then the lambda has an implicit hard reference to the object. Thus the scheduled task should be cancelled in thecleanup()
method which should then be called by the owning object accordingly.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description void
cleanup()
Does any cleanup that would prevent this instance from being eligible for garbage collection like cancelling scheduled repeated tasks or callingcleanup
on "owned" cleanupable objects.
-