System.gc()的和runtime.gc之间差()System、gc、runtime

2023-09-05 05:56:34 作者:阴天的旅行

之间的区别是什么的System.gc() Runtime.gc()

推荐答案

两者都是一样的。 的System.gc()实际上等同于 Runtime.gc()的System.gc()内部调用 Runtime.gc()

Both are same. System.gc() is effectively equivalent to Runtime.gc(). System.gc()internally calls Runtime.gc().

唯一不同的是的System.gc()是一个类的方法,其中的 Runtime.gc()是一个实例方法。因此,的System.gc()更方便。

The only difference is System.gc() is a class method where as Runtime.gc() is an instance method. So, System.gc() is more convenient.