• Tidak ada hasil yang ditemukan

Java Week 6: Q4 - Nptel

N/A
N/A
Protected

Academic year: 2024

Membagikan "Java Week 6: Q4 - Nptel"

Copied!
3
0
0

Teks penuh

(1)

02/07/2020 Programming in Java - Course

https://onlinecourses.nptel.ac.in/noc20_cs08/progassignment?name=145 1/3

Due on 2020-03-12, 23:59 IST

Java Week 6: Q4

Execution of two or more threads occurs in a random order. The keyword 'synchronized' in Java is used to control the execution of thread in a strict sequence. In the following, the program is expected to print some numbers. Do the necessary use of 'synchronized' keyword, so that, the program prints the output in the following order:

---OUTPUT---

5 10 15 20 25 100 200 300 400 500

--- Sample Test Cases

Input Output

X

NPTEL (https://swayam.gov.in/explorer?ncCode=NPTEL) » Programming in Java (course)

(https://swayam.gov.in)

(https://swayam.gov.in/nc_details/NPTEL)

[email protected]

Announcements (announcements)

About the Course (https://swayam.gov.in/nd1_noc20_cs08/preview) Ask a Question (forum) Progress (student/home) Mentor (student/mentor)

Course outline

How does an NPTEL online course work?

Week 0 : Week 1 : Week 2 : Week 3 : Week 4 : Week 5 : Week 6 :

Lecture 26 : Demonstration- X (unit?

unit=7&lesson=40) Lecture 27 : Multithreading- I (unit?

unit=7&lesson=41) Lecture 28 : Multithreading-

(2)

02/07/2020 Programming in Java - Course

https://onlinecourses.nptel.ac.in/noc20_cs08/progassignment?name=145 2/3

Test Case 1

5 10 15 20 25 100 200 300 400 500

Test Case 2

5 10 15 20 25 100 200 300 400 500

The due date for submitting this assignment has passed.

As per our records you have not submitted this assignment.

Sample solutions (Provided by instructor)

Week 7 : Week 8 : Week 9 : Week 10 : Week 11 : Week 12 : DOWNLOAD VIDEOS

II (unit?

unit=7&lesson=42) Lecture 29 : Demonstration- XI (unit?

unit=7&lesson=43) Lecture 30 : I- O Stream-I (unit?

unit=7&lesson=44) Quiz :

Assignment 6 (assessment?

name=98) Java Week 6:

Q1

(/noc20_cs08/progassignment?

name=142) Java Week 6:

Q2

(/noc20_cs08/progassignment?

name=143) Java Week 6:

Q3

(/noc20_cs08/progassignment?

name=144) Java Week 6:

Q4

(/noc20_cs08/progassignment?

name=145) Java Week 6:

Q5

(/noc20_cs08/progassignment?

name=146) Feedback For Week 6 (unit?

unit=7&lesson=154)

class Execute{

// Just add 'synchronized' in the method synchronized void print(int n){

for(int i=1;i<=5;i++){

System.out.println(n*i);

try{

Thread.sleep(400);

}catch(Exception e){

System.out.println(e);

} } }

} // Ending Execute class

class Thread1 extends Thread{

Execute t;

Thread1(Execute t){

this.t=t;

}

public void run(){

t.print(5);

} }

class Thread2 extends Thread{

Execute t;

Thread2(Execute t){

this.t=t;

}

public void run(){

t.print(100);

} }

public class Question64{

public static void main(String args[]){

Execute obj = new Execute();//only one object Thread1 t1=new Thread1(obj);

Thread2 t2=new Thread2(obj);

t1.start();

12 34 56 78 109 1112 1314 1516 1718 1920 2122 2324 2526 2728 2930 3132 3334 3536 3738 3940 41

(3)

02/07/2020 Programming in Java - Course

https://onlinecourses.nptel.ac.in/noc20_cs08/progassignment?name=145 3/3

Assignment Solution Books

Live Interactive Session

t2.start();

} } 4243 4445

Referensi

Dokumen terkait

Now, if a number from group x is in the new sequence, then no number in group 11 − x is allowed to be in the sequence, otherwise the sum of two numbers in those groups will

The first numbers in each group form a sequence which goes up by 12 each time; that is true also for the second numbers, the third ones and the

A sequence of digits is formed by writing the digits from the natural numbers in the order that..

The survey is carried out in coast of Bayuran in the Regency of Jepara, Central Java where the sand is highly magnetic compared to other iron sand locations in Java [3].. The

The difference in height shows that the height of the place for each type of orchid is not the same, some orchids in West Java and East Java can grow at an altitude of up to 800

There is a week four effect doesn’t exist in Indonesia stock exchange and in Kuala Lumpur stock exchange. Keyword : Efficiency of the capital market, Day of week effect, Week

The highest proportion of traffic accidents is in West Java, Central Java, East Java, DKI Jakarta, and North Sumatra.Djaja et al., 2016 Meanwhile, data analysis of the National

Score: 0 Accepted Answers: tr SET Toolkit can be invoked in command line by using the following command: se-toolkit toolkit setoolkit None of the above No, the answer is