Concept of multi threading
what are threads
fconcumney
Parallelism
How to create thread
multi traded code
Steps for writing
Can threads them data
if
then how
yes
Synchronization trailer
Implementations in
Jang
NOTES I Yes
Recording Yee No
te te
Scaler Not a Scaler student
101
Talented't'd If
I build
Irun
KETA
Ingrain Something that can be executed to
cause a particular action
I when program is running
proceed
it becomes
proofs
on CPO
process executes
all data for a process is stored
at RAM
I
2 process a
Chong tab
of
ons
t
b
thread's unit Cpu execution
of
q smallest
I
basic
a core executes threads
4 Every process has atleast one thread
dansmainI
I bout Hello world t
multiple methods
doc clams blocks
of
code all will be
thread
psumci main thread
Soul Hello world Ii
Until or unless we dont create separate
fuseads the entire
process would be
executed in a thread
single
cone a
Pentium a
single
i3
it 46861
it
a
Concurrency parallelism
de f
machine executes machine egecutes
certain set tasks two or more set
a
of of
tasks
illusion parallely truly parallely
overawi
not g but
running at
the same time
calculator
I E T w Me
ContentSwetained
Muff
con
If
we 2
IF
is is it concurrent
If something parallel
And Yes
is concurrent is if parallel
If something
Am I NO
Program Process Threads Core
YonTcors
I
concurrency my
main pthread inJava
process executes
we
with f
tf
dont specifically create separate threads
if
i
think in terms of what tasks you want to do
in parallel
Alfred Create a multi threaded program where we
can helloworld from a separate thread
print
Step IDENTIFY THE TASK THAT You WANT to
DO PARALLEY
print thawing
Stef CREATE CLASSES FOR ALL TASKS IDENTIFIED
A Class name should be a noun doing
a verb
class HelloworldPrinter
make the classes implement Runnable interface
step
class HelloworldPrinter implements Runnable
Runnable interface has a method called rune this method
should contain the actual taste that we want todo
Sky Implement the rural method
Printer implements Runnable
class Helloworld
public void runs
south Hello world
y
Taste definition is completed fromstepstoy
Steps Create the threads to implement the tasty
go to
a
you want to
place from where
egecute the code
b create the object taste class
of
HelloworldPrinter hwy new HelloworldPrinter
g create a thread using taste object
Thread t new thread bwp
d Start the lepead
t starts
plumes
wait south hello world
Hello
worth
Thread t new thread hemp
t nunc
E efaster
Helloworld main
Obp
main
time t runs the run C method on the
main iii concert thread never creates
thread a new thread
egecute the nuns method on
B the new thread
Helloworld
t start a new thread e runs on new thread
t run Ct a rant on current thread
Angry Print I to 100 and all
of them through different
threads
sat
Taste a Print
Number
t
Numberprinter in constructor pass theno
I to be printed
NumberPrinter I
Numberprinter z
i
Step2 Reurable
Step Run method
steps e threads and Start
1 to 100
for
4 Numberprinter
t
np
new NumberPointerei
new thread
Thread np i
t stane
g
Fit
DSA
Java
EFFIE
Python
Teams a Jana Mysql
DSA s
months
e
BE
9yd
E weeks
say a 3 PSE FEA BE
AE 9
LD Der i 3 t money
Minty peep s as 2Monty
contest
eminent Product
Data ftp.wgm DSA Management
rug
UK
UY
of threads 2x no
ofcotes
thread creation is a
maintaining difficult
Job for developer
1 defined a taste
in Created a thread
for the task
instantiated
t
Egecutorframework
Space
Lusablendth epa
santy
I time userocket
every new taste create a new rocket
mn
Eoy
Tiit
Fitted
Faecutorframeway
Reusing
threads
howmany threads and tasks everything will be
iii
taken
cand
Runnable Thread creation
biugeneration
a
G tonof
pig
aFTag
item
Gas shippingcharges t
separate
thread
among
Return data in multi threaded code
a interface that is used to define
ELBE a taste which also returns some
data
Assay a heverate 2 random nos and add them These
random nor should be generated in
separate
threads
Stf Define the fash
step Implement Callable interface
stay Define the return type and implement
call method
int RB
main int Fy
gens
htt raffenecutor sunbit generator
edit rank executor subit generators
fukin
O O
y y
tf
ME'd was
futureintegers rant executor subit generator
futureintegers feutor.suwbitfgenerator
fy.int sung
ranta ranz.gov
It the
until
value is
so
4