GC test

xiaoxiao2021-03-06  120

The following code can be used to test the work of GC, the Finalize method is the key public class gctest {public static void main (String [] args) throws interruptedException {// rungc (); for (int i = 0; i <100) throws interruptedException {// rungc (); for (INT i = 0; i <100) ; i ) {newobj ();

System.out.println ("A total of a total of objects:" ai); system.out.println ("Number of objects for garbage recycling:" A.GC);} static void newobj () {for (int) i = 0; i <1000; i ) {Object O = new a ();}} static void rungc ()}} static void rungc ()}} static void rungc ()}} static void rungc ()}} g et = 0; public static int i = 0; public static int i = 0; public static int i = 0; Static int GC = 0; int II = i ; public string toString () {return "object" ii;} public void finalize () {//system.out.println ("GC: " this.tostring ()) GC ;}}}}

转载请注明原文地址:https://www.9cbs.com/read-98923.html

New Post(0)