gcRadar SingleObjectSingleThreadedLog4jMonitor Example
/*This file is part of gcRadar.
gcRadar is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation version 3 of the License.
gcRadar is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with gcRadar. If not, see <http://www.gnu.org/licenses/>.
*/
package test;
import com.gcr.monitors.SingleObjectSingleThreadedLog4jMonitor;
public class SingleObjectSingleThreadedLog4jMonitor_Test
{
Integer ro = new Integer(678);
public static void main(String[] args)
{
SingleObjectSingleThreadedLog4jMonitor_Test gcMoniterTest = new SingleObjectSingleThreadedLog4jMonitor_Test();
gcMoniterTest.doTest();
}
private void doTest()
{
System.out.println("GCMoniterTest.doTest()");
SingleObjectSingleThreadedLog4jMonitor log4jMonitor = new SingleObjectSingleThreadedLog4jMonitor();
for (int i = 0; i < 100; i++)
{
Integer o = new Integer(5);
log4jMonitor.addObject(o, "MyObject - " + i);
}
log4jMonitor.startMonitoring();
log4jMonitor.addObject(ro);
try
{
Thread.sleep(5000);
}
catch (InterruptedException e)
{
e.printStackTrace();
}
System.out.println(log4jMonitor.getPendingObjectsCount());
System.out.println(log4jMonitor.getPendingObjects());
try
{
Thread.sleep(2000);
}
catch (InterruptedException e)
{
e.printStackTrace();
}
ro = null;
try
{
Thread.sleep(2000);
System.gc();
System.out.println(log4jMonitor.getPendingObjectsCount());
System.out.println(log4jMonitor.getPendingObjects());
}
catch (InterruptedException e)
{
e.printStackTrace();
}
}
}