Java Programing laungage

Core Java Tutorial

Introduction of Core Java

How To Install JDk and Set of Path

Syntax of java Program

Difference between Java and C/C++

Advantage and Disadvantage of Java

What is Java

Why Java is not Pure Object Oriented Language

Java has Following Features/Characteristics

Limitation of Java Language and Java Internet

Common Misconception about Java

Simple Program of Java

Integrated Development Environment in java

Compile and Run Java Program

Applet and Comments in Java

Tokens in Java

Keywords in Java

Identifier and Variables in Java


Data Type in Java

Assignments and Initialization in Java

Operators in Java

Rule of Precedence in Java

Operator on Integer and Separators in Java Programming

Java Control Flow of Statements

If and If-else Selection Statement

Nested If-else and If-else-If Selection Statement

switch case and conditional operator Selection Statement

for and while Loop

do..while and for each Loop

break and labeled break statement

continue and labeled continue statement

return Statement and exit() Method

Escape Sequence for Special Characters and Unicode Code

Constants and Block or Scope

Statement in Java

Conversions between Numeric Types in Java

Import Statement in Java

User Input in Java using Scanner Class

User Input in Java using Console Class

Array in Java

One Dimensional Array

Two Dimensional Array

Two Dimensional Array Program

Command Line Argument in Java

String args Types in Java

Uneven/Jagged array in java

Math Class Function and Constant

Math Class all Function used in a program

Enumerated Types in Java

Object Oriented Programming v/s Procedural Programming

Object Oriented Programming Concepts in Java

Introduction to Class,Object and Method in Java

Class Declaration in Java

Class & Objects in java

Encapsulation in Java

Modifiers/Visibility for a Class or Interrface or member of a Class

Polymorphism in Java

Runtime polymorphism (dynamic binding or method overriding)

Thread in Java
Previous Home Next

The first concept to define is that of the process. Processes is program that is executing. Multiple process may run concurrently in CPU. The multitasking is feature of O/S where more than one process can be executed.

Threads are fundamental unit of dispatchable code. A process can have multiple threads. In other words thread s are light weight processes. These threads can be executed concurrently. Threads increase utilization of CPU cycles.

Advantage of Threads over Processes

  1. Threads are light weight tasks so they don't require there own address space but they threads of same processes share same address space whether process are heavyweight hence they need their own address space.
  2. Interprocess communication of processes are expensive and limited. But interthread communication is inexpensive.
  3. Context switching of processes are costly whether context switching of threads are inexpensive.
Life Cycle of Thread

Thread Life cycle is given below:

This life cycle is same as life cycle of process. Thread created then it goes in state runnable means thread is ready to run. Then it goes to state running. If any other thread with high priority came or it is waiting for some resources then it blocked. After accomplishing task it goes into dead state. From blocked state it will go to dead state if it killed by O/S forcefully.

Main Thread

The main thread is first thread that is running since beginning of prorgramm. It is important because

  1. Other child Threads spawned from it.
  2. This is last thread to finish execution and perform all shutdown action.
Implementing Threads in Java

Thread implemented by java either using Thread class or using Runnable interface.

Previous Home Next