part 1 semaphorelab.zipSuppose we have a class:public class Foo { public void first() { print("first"); } public void second() { print("second"); } public void third() { print("third"); }}The same...

1 answer below »

part 1 semaphorelab.zip


Suppose we have a class:



public class Foo {



public void first() { print("first"); }



public void second() { print("second"); }



public void third() { print("third"); }


}


The same instance of Foo will be passed to three different threads.


Thread A will call first(), thread B will call second(), and thread C will call third().


Design a mechanism and modify the program to ensure that:


first is printed first.


second is printed second.


third is printed third.



Download and import the attached project.


You must use Semaphores and you can only modify theFooclass!






part 2 semaphorelab1. zip


Suppose we have a class:



public class Foo {



public void first() { print("first"); }



public void second() { print("second"); }



public void third() { print("third"); }


}


The same instance of Foo will be passed to three different threads.


Thread A will call first(), thread B will call second(), and thread C will call third().


Design a mechanism and modify the program to ensure that:


first is printed first.


second is printed second.


third is printed third.



Download and import the attached project.


You must use Semaphores and you can only modify theMainclass!






synchronizedmethodstart.zip


Download and impost the attached project.


// in FindPalindrome
// 1 Complete the run method
// 2 complete the private boolean isPaladrome(long number)
// In Main
// 3 Create 4 FindPalindrome objects
// first should look like this
// FindPalindrome fp = new FindPalindrome((n)-> print(n),start, end);
// make start = end + 1



// and end = end + 1000000 for each new FindPalindrome
// 4 Create 4 threads with the FindPalindrome
// 5 Start the threads
// What's wrong?
// Fix it!









Answered 3 days AfterNov 07, 2022

Answer To: part 1 semaphorelab.zipSuppose we have a class:public class Foo { public void first() {...

Vikas answered on Nov 11 2022
56 Votes
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here