Important Features of Java – Multithreading, AWT
In this tutorial you will learn about Important Features of Java – Multithreading, AWT and Event Handling, Networking, Socket and Database Connection
There are many features of Java. Some of them namely are explained below.
A fundamental concept of computer programming is the idea of handling more than one task at a time. Within a program these separately running pieces are called threads and the general concept is called multithreading.
The Java Virtual Machine allows an application to have multiple threads of execution running concurrently. Each thread has a priority. Threads with higher priority are executed in preference to threads with lower priority. When a Java Virtual Machine starts up there is usually a single non-daemon thread. The Java Virtual Machine continues to execute threads until either of the following occurs.
The exit method of class Runtime has been called and the security manager has permitted the exit operation to take place.
All threads that are not daemon threads have died either by returning from the call to the run method or by performing the stop method.
There are two ways to create a new thread of execution. One is to declare a class to be subclass of Thread. This subclass should override the run method of class Thread. An instance of the subclass can then be allocated and started.
AWT and Event Handling
The original design goal of the graphical user interface called as GUI library in Java was to allow the programmer to build a GUI that looks good on all platforms. The Java Abstract Window Toolkit called as AWT produces a GUI that looks equally good on all systems. Thus much of the situation has been improved with the Java Abstract Window Toolkit AWT by using a very good object oriented approach also with the use of Java Beans which is a component programming model that is very useful for the creation of easy and effective visual programming environments. The concept of swings is also a powerful method which is a rich set of easy to sue Java Beans that can be easily dragged and dropped to create GUI that user can feel satisfied. Swing has the main attribute of pluggable look and feel by which it means that depending on the user’s platform and operating systems the GUI can dynamically be changed as pet the needs of the user in an effective way. Event driven programming is the concept of attaching or associating events to code like in the actions of mouse click or key press or selection of menu and so on. Thus the code attached to these events gets fired when the action or event occurs. This is very important concept supported by Java in an efficient way which takes care of interactive programming methodology thus making it a powerful programming tool.
This is a very important feature of Java and in Java it is possible to achieve networking without much effort because of the powerful features possessed by it. In other words the concept of networking has become so easy in Java because the underlying details of networking is abstracted and taken away and is taken care of within the JVM and local machine installation of Java.
In Java one creates a socket to make a connection to the other machine and thereby gets an InputStream and OutputStream from the socket with the appropriate converters namely Reader and Writer which helps to treat the connection as an IO stream object. Generally there are two stream-based socket classes namely a ServerScoket that a server uses to listen for incoming connections and a Socket that a client uses in order to initiate a connection. Once a client makes a socket connection the ServerSocket returns using appropriate method namely accept() method a corresponding server side socket through which direct communications takes place. From this point one gets a true Socket to Socket connection and one can treat both ends the same way as they are same.
The greatest feature of Java is its ability to build platform-independent client/server database applications. In Java this is possible with Java Database Connectivity also called as JDBC in short. Java Database Connectivity is designed to be platform independent and so one need not worry about the database one use while they are programming.
This is achieved by JDBC by the use of driver manager that dynamically maintains all the driver objects that the database queries need. Like many of the API’s in Java, Java Database Connectivity is also designed for simplicity.
There are numerous features of Java and of these above are some of the features of Java which makes Java powerful and popular among programming language.