You are on page 1of 1

‎New

‎ ew: Whenever a new thread is created, it is


N ‎ yntax:
S
‎always in the new state. For a thread in the ‎ public static final Thread.State NEW
‎new state, the code has not been run yet and ‎ -----It represents the first state of a
‎thus has not begun its execution. ‎thread that is the NEW state.
‎ ‎
‎ ‎public static final Thread.State RUNNABLE
‎--------It represents the runnable state.It
‎Active ‎means a thread is waiting in the queue to
‎run.

‎ hen a thread invokes the start() method, it
W
‎public static final Thread.State BLOCKED
‎moves from the new state to the active state.
‎---------It represents the blocked state. In
‎The active state contains two states within it:
‎this state, the thread is waiting to acquire a
‎one is runnable, and the other is running.
‎lock.

‎ ew
N ‎

‎ ultithreading in Java is a process of
M ‎Active ‎public static final Thread.State WAITING
‎executing multiple threads simultaneously. ‎Blocked / Waiting ‎--------It represents the waiting state.
‎ ‎Timed Waiting ‎Blocked/waiting
‎ ‎Terminated

‎ henever a thread is inactive for a span of
W
‎time (not permanently) then, either the thread
‎is in the blocked state or is in the waiting
‎state.

‎Terminated

‎ erminated: A thread reaches the termination


T
‎MultiThreading ‎state because of the following reasons:

‎When a thread has finished its job, then it
‎exists or terminates normally.

‎ dvantage of
A
‎Multithreading: It doesn't
‎block the user because threads are
‎independent and you can perform multiple
‎operations at the same time.

‎2) You can perform many operations
‎together, so it saves time.

‎3) Threads are independent, so it doesn't
‎affect other threads if an exception occurs in
‎a single thread.

‎ hy use Synchronization?
W ‎ ypes of Synchronization
T
‎ ynchronization in Java is the capability to
S
‎The synchronization is mainly used to ‎There are two types of synchronization
‎control the access of multiple threads to any
‎ ‎
‎Synchronization ‎shared resource.
‎--To prevent thread interference. ‎--Process Synchronization

‎--To prevent consistency problem. ‎--Thread Synchronization

‎ ‎

J‎ ava Networking Terminology


‎--The widely used Java networking
‎Programming in Java J‎ ava Networking is a concept of connecting
‎two or more computing devices together so
‎terminologies are given below:
‎ dvantages of networking:
A ‎
‎that we can share resources.
‎ ---Sharing resources ‎--IP Address

‎ ---Centralize software ‎--Protocol
‎Networking ‎Java socket programming provides facility to
‎ management ‎--Port Number
‎share data between different computing
‎ ‎--MAC Address
‎devices.
‎ ‎--Connection-oriented and connection-less

‎protocol

‎--Socket

‎ e can convert String to an int in java using


W
‎Integer.parseInt()
‎method. To convert String
‎into Integer
‎java Conversion ‎, we can use Integer.valueOf()
‎method which returns instance of Integer
‎class.

‎ rrayList list=new ArrayList();//creating old


A
‎ rrayList class uses a dynamic array for
A ‎non-generic arraylist
‎storing the elements. It is like an array, but ‎ i‎mport java.util.*;
‎Array List ‎there is no size limit. We can add or remove ‎ArrayList<String> list=new ArrayList< ‎
‎elements anytime. ‎String>();//creating new generic arraylist

‎ ashMap class implements the Map interface


H ‎ ashMap<K,V>, where K stands for key and
H
‎Hash Map ‎which allows us to store key and value pair. ‎V for value.

You might also like