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 …

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 …

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 …

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 …

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, …

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 …

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 …

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 …

Garbage Collection Program in Java

Overriding finalize method: In the above application, we have created unreferenced objects. GC thread is not invoking finalize() method to delete those objects. GC thread invokes by JVM only when the memory is running low. …

Garbage Collection in Java

Garbage Collection: We create objects in memory (Heap area). Every object has a reference variable. Garbage collection is a mechanism of deleting objects which are no longer use in the application. Object is eligible for …

Courses Enquiry Form