Category: Java

  • Resource Optimization with Java SE 7

    The typical Java application manipulates several types of resources such as files, streams, sockets, and database connections. Such resource optimization must be handled with great care, because they acquire system resources for their operations. Thus, you need to ensure that they get freed even in case of errors. Indeed, incorrect resource management is a common […]

    Posted in: Java

  • Inter-thread communication

    Inter-thread communication or Co-operation is all about allowing synchronized threads to communicate with each other. Cooperation (Inter-thread communication) is a mechanism in which a thread is paused running in its critical section and another thread is allowed to enter (or lock) in the same critical section to be executed.It is implemented by following methods of […]

    Posted in: Java

  • Deadlock in java

    Deadlock in java is a part of multithreading. Deadlock can occur in a situation when a thread is waiting for an object lock, that is acquired by another thread and second thread is waiting for an object lock that is acquired by first thread. Since, both threads are waiting for each other to release the […]

    Posted in: Java

  • Static synchronization

    If you make any static method as synchronized, the lock will be on the class not on object. Problem without static synchronization Suppose there are two objects of a shared class(e.g. Table) named object1 and object2.In case of synchronized method and synchronized block there cannot be interference between t1 and t2 or t3 and t4 […]

    Posted in: Java

  • Garbage Collection

    In java, garbage means unreferenced objects. Garbage Collection is process of reclaiming the runtime unused memory automatically. Advantage of Garbage Collection: It makes java memory efficient because garbage collector removes the unreferenced objects from heap memory. It is automatically done by the garbage collector so we don’t need to make extra efforts. How can an […]

    Posted in: Java

  • Shutdown Hook

    The shutdown hook can be used to perform cleanup resource or save the state when JVM shuts down normally or abruptly. Performing clean resource means closing log file, sending some alerts or something else. So if you want to execute some code before JVM shuts down, use shutdown hook. When does the JVM shut down? […]

    Posted in: Java

  • Daemon Thread

    Daemon thread in java is a service provider thread that provides services to the user thread. Its life depend on the mercy of user threads i.e. when all the user threads dies, JVM terminates this thread automatically. There are many java daemon threads running automatically e.g. gc, finalizer etc. You can see all the detail […]

    Posted in: Java

  • Remote Method Invocation

    The Remote Method Invocation (RMI) is an API that provides a mechanism to create distributed application in java. The RMI allows an object to invoke methods on an object running in another JVM. The RMI provides remote communication between the applications using two objects stub and skeleton. Understanding stub and skeleton RMI uses stub and […]

    Posted in: Java

  • JDBC API

    This JDBC tutorial covers all the topics of JDBC with the simple examples. JDBC is a Java API that is used to connect and execute query to the database. JDBC API uses jdbc drivers to connects to the database. Why use JDBC? Before JDBC, ODBC API was used to connect and execute query to the […]

    Posted in: Java

  • Java Reflection API

    Java Reflection APIĀ is a process of examining or modifying the run time behavior of a class at run time. The java.lang.Class class provides many methods that can be used to get metadata, examine and change the run time behavior of a class. The java.lang and java.lang.reflect packages provide classes for java reflection. Where it is […]

    Posted in: Java