GF4J 0.9.4 Beta

gameframe.util
Class ObjectPreserver

java.lang.Object
  |
  +--gameframe.util.ObjectPreserver
All Implemented Interfaces:
java.lang.Runnable

public class ObjectPreserver
extends java.lang.Object
implements java.lang.Runnable

This class has methods to ensure that an object is never garbage collected. It is very handy when using singletons (classes that have one static reference to itself) as these might be garbage collected in some Java runtimes.

Since:
GameFrame for Java 0.9.2
Version:
GameFrame for Java 0.9.4
Author:
Pasi Keränen 20. Dec 1999

Method Summary
static void preserveObject(java.lang.Object object)
          The objects passed to this method will be protected from garbage collection until they are released by the unpreserveObject method.
 void run()
          The threads run method that does nothing else than keeps this object alive.
 void stop()
          Stops the garbage collector preventing thread.
static void unpreserveObject(java.lang.Object object)
          The objects passed to this method will no longer be protected from garbage collection.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

run

public void run()
The threads run method that does nothing else than keeps this object alive.
Specified by:
run in interface java.lang.Runnable
Since:
GameFrame for Java 0.9.2

stop

public void stop()
Stops the garbage collector preventing thread.
Since:
GameFrame for Java 0.9.2

preserveObject

public static void preserveObject(java.lang.Object object)
The objects passed to this method will be protected from garbage collection until they are released by the unpreserveObject method.
Parameters:
object - The object to be added to the preserved set of objects.
Since:
GameFrame for Java 0.9.2

unpreserveObject

public static void unpreserveObject(java.lang.Object object)
The objects passed to this method will no longer be protected from garbage collection.
Parameters:
object - The object to be removed from the preserved set of objects.
Since:
GameFrame for Java 0.9.2

GF4J 0.9.4 Beta