Monday 16 January 2017

Why we use constructor in java

There is no concept of destructor in JAVA. The concept of garbage collection deletes all the variables and functions of the program that’s execution is completed. So all the instance variables are automatically initialized with there zero values at the time of creation of the object, because the memory is cleared by the garbage collection concept.

If user wants to delete an object from the memory then the finalize( ) function can be used to perform those type of operation. That means, using finalize () function, particular object can be deleted as the choice of the user but by the garbage collection all the objects are deleted after execution of the program which is performed automatically by the JVM.

Java constructor and class


Wednesday 4 January 2017

What is meant by multithreading in java

Advanced multithreading in java

Multithreading is those type of programming concept which is used to implement the concept of multitasking. Thread means, small program which can be executed at a time. Multithreading means more then one smalls program which are executed simultaneously not concurrently using small span of time and using the round robin scheduling.

We know that JVM is an operating system over the operating system, so in JVM a scheduler is present which is responsible to implement multithreading. In multithreading threads are different states :-

(1)          New born state
(2)          Ready state
(3)          Running state
(4)          Suspended state (temporarily)
(5)          Terminated state or killed
                                                  
In JAVA a thread class is present which is used to implement the concept of multithreading. A run( ) function is present in the thread class which is used to run a thread.

An init( ) function is present, which is used to initialize a thread or new born thread is created. Start( ) function is also present, which is used to ready a thread to execute.

Stop( ) function is present which is responsible to terminate a thread. For temporarily suspended of thread three functions are present and they are-

(1)          Sleep
(2)          Suspended
(3)          Wait

The sleep( ) is automatically deactivated after specific time given in millisecond in the sleep( ) function. The suspended( ) function is deactivated when a resume( ) function is called. Wait function is deactivated when a notify( ) is called. 

This blog written by Jitendra Kumar (JAVA Trainer at Vtech Academy of Computers)- Java Certification and Java Training Courses

What is list in data structure

List: - List is a linear data structure in which elements are arranged in random order. That means list is those type of linear data struc...