Docsity
Docsity

Prepare for your exams
Prepare for your exams

Study with the several resources on Docsity


Earn points to download
Earn points to download

Earn points by helping other students or get them with a premium plan


Guidelines and tips
Guidelines and tips

Understanding Concurrency and Threads in Java Programming, Slides of Data Structures and Algorithms

An introduction to concurrency, a process that allows computers to work on multiple tasks simultaneously. It covers the basics of concurrent programming, including the difference between processes and threads, and how to create and manage threads in java using the thread class and the runnable interface. It also discusses the concept of sleeping threads and their use in java programming.

Typology: Slides

2012/2013

Uploaded on 04/23/2013

saratey
saratey 🇮🇳

4.3

(10)

87 documents

1 / 9

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
15-121
Docsity.com
pf3
pf4
pf5
pf8
pf9

Partial preview of the text

Download Understanding Concurrency and Threads in Java Programming and more Slides Data Structures and Algorithms in PDF only on Docsity!

  • 15-

Concurrency



Concurrency is the process of working on multipletasks at the same time.



Operating Systems supports concurrency heavily.



It is allowing computers to use resources moreeffectively.

Threads



A Thread is a program unit or process that is executedindependently of other processes



Thread can be considered a “light-weight” process.



Threads help carry out two or more tasks at the sametime



Java virtual machine executes all threads in “parallel”

Threads



Threads exists within a process



Each process has at least one thread



Each process has its own private run-time resources



Multiple threads within a process can share resourceswithin the process

Runnable Interface

public interface Runnable {

void run();

} public class MyClass implements Runnable{

public void run(){

// thread action

Sleeping Threads



Thread.sleep(time in miliseconds)



A great way to pause the current thread



Read more at



http://java.sun.com/docs/books/tutorial/essential/concurrency/index.html