Skip to main content

Posts

Showing posts from December, 2015

Java System Class --- a Utility often used

Java System Class The System class  is a final class and  contains many useful fields and methods which are quite useful utilities like: standard input, output and error, for loading files and libraries. It helps to provide access to externally defined properties and variables. It also contain utility methods to quickly copy an array To get the environment variables. Fields in the System Class: static PrintStream err : The standard error output stream static InputStream in : The standard input stream static PrintStream out: The standard output stream The class has many useful methods , lets see few important methods: static void arraycopy (Object src, int srcPos, Object dest, int destPos, int length): It is used to copy array from src array to destination array starting at srcPosition and starts copying at destPosition and copies the length specified from source to destination. System Properties Methods : It contains method to get , set and clear sys...

Thread -- A Java Class which runs nearly every platform

Thread: Multithreading, Runnable, Thread Class, Callable, DeadLock, Synchronization   Thread is a part of program execution which executes with different set of  variable values . In JVM multiple threads can be running concurrently to server a purpose. When multiple thread executes in program that is called Multi-Threading . Life Cycle Of Thread: Thread could be in 5 states : 1) New 2) Runnable 3) Running 4) Waiting/Blocked 5) Dead/Terminated New : The thread is in new state if you create an instance of Thread class but before the invocation of start() method.     Runnable: The thread is in runnable state after invocation of start() method, but the thread scheduler has not selected it to be the running thread. Running: The thread is in running state if the thread scheduler has selected it. Waiting/Blocked: This is the state when the thread is still alive, but is currently not eligible to run. Terminated: A thread is in terminated ...