0% found this document useful (0 votes)
27 views2 pages

Concurrent Programming PDF

The document discusses concurrent programming and threads. It defines what a thread is and explains thread execution. It also covers creating threads by extending the Thread class or implementing Runnable. The document discusses challenges of threads like deadlock and starvation and synchronization techniques.

Uploaded by

xdilix
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
27 views2 pages

Concurrent Programming PDF

The document discusses concurrent programming and threads. It defines what a thread is and explains thread execution. It also covers creating threads by extending the Thread class or implementing Runnable. The document discusses challenges of threads like deadlock and starvation and synchronization techniques.

Uploaded by

xdilix
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Concurrent Programming

Nj thread nenkupton nje kontroll te vetem te rrjedhes Brenda


programit.
Nje Thread of Execution eshte thread I startuar nga Procesimi
kryesor;
Main thread of Execution procesi kryesor.
Perdorimi i shume thread-eve brenda nje programi te vetem, dhe
ekzekutimi ne te njejten kohe i tyre quhet Concurrent Programming.
Fazat e Thread:
1. New Thread
2. Runnable
3. Not Runnable
4. Dead
Krijimi i nje Thread:
1.Duke derivuar klasen Thread
-public class UbtThread extends Thread
2.Duke implementuar interface-in Runnable
-public class UbtThread implements Runnable

Metoda run() duhet mbishkruar nga klaset qe derivojn klasen thread


apo implementojne interface-in Runnable.
Kjo metode thirret me ane te Metodes start() te classes thread.
Sfidat e Threadeve:
1. Perjashtimi Reciprok
2. Sinkonizimi
3. Scheduling
4. Bllokimi
Llojet e Bllokimit:
1. Deadlock
2. Livelock
3. Starvation

Fjala kyqe Synchronize perdoret qe te trajtoje pjese te kodit te cilen


nuk duhet te kene qasje ne te njejten kohe dy thread-e.

Startimi i Thread-eve behet duke i thirrur instances se tij metoden


start();
Shembull kemi nje klase ThreadTest qe derivohet nga Thread:
ThreadTest th = new ThreadTest();
Th.start();

Startimi i klasave qe implementojne Runnable:


ThreadRunnable thR = new ThreadRunnable();
Thread th = new Thread(thR);
Th.start();

You might also like