Core Java Archive

System.gc() in Java

In the following example, finalize method doesn’t execute implicitly as the memory is not running low: System.gc(): System class is providing pre-defined function called gc(). gc() method invokes Garbage collector. We invoke Garbage collector explicitly …

Factory Class in Java

Factory Class: These are called design pattern classes. These objects have special behavior from plain objects. We need to implement following rules to get that behavior Rules: Class is public – Object is visible to …

Singleton Class in Java

Singleton class Rules: Class is public – Object is visible to other objects in communication. Constructor is private – Other classes cannot instantiate directly. Every class has factory method that is static. Factory method returns …

Runtime class in Java

Runtime class: It is pre-defined class. It is belongs to java.lang package. Runtime class represents Java Virtual Environment(JVM) instance. For entire java application execution, only one JVM instance will be created. It is singleton class, …

Runtime gc() in Java

Runtime.gc(): Runtime class has non static gc() method. It is used to start garbage collector on request. Runtime object representing JVM directly. We request the JVM directly to start Garbage collector. exec(String command): Pre-defined method …

Java Runnable Interface

Creating Thread using Runnable: It is an interface. It contains only one specification called run() method. We need to override run method to place thread logic. The class which is implementing Runnable interface is called …

Java Synchronization

Synchronization: The concept of allowing thread sequentially when multiple threads trying to access a resource. Every application has critical section need to be synchronized. We cannot synchronize the entire object. We can synchronize only a …

Block Synchronization in java

Block synchronization : Synchronized block is used to lock an object for any shared resource. Scope of synchronized block is smaller than the method. Generally we synchronize methods as shown in the above discussion. Block …

wait() and notify() in java

wait, notify and notifyAll(): We can implement inter thread communication using these methods. wait(), notify() and notifyAll() methods are belongs to Object class. We must use these methods with synchronized context of java application. wait() …

Inner classes in Java

Inner class: Define a class inside another class. Inner class is also called nested class. Inner classes clearly have two benefits one is ‘name control’ and second one is ‘access control’. Defining more than one …

Courses Enquiry Form