In control task1... one 2nd Check in task2... 3 4 In control task1... 5 6 Check in task2... 7 8 In contr

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

URGENT!!

In control task1...

one

2nd

Check in task2...

3

4

In control task1...

5

6

Check in task2...

7

8

In control task1...

9

10

Transaction completed

Check in task2...

Transaction completed

 

Above is the two tasks (tasks) working in sequence and printing the numbers from 1 to 10 on the screen. These tasks are two Java classes named task1 and task2 and they are connected to two different threads. These tasks alternately call the method named artir() of an object created from a class named “artis”, that is, writing the numbers to the console is done by the method named artir() in the “artis” class. You can design the parameters and return value of the artir() method as you wish. The creation of the "artis" class object, tasks and threads is seen in the following snippet.

 

public class Final_question1 {

 

public static void main(String[] args) {

increment a = new increment(1, 2, 10);

//Each task will print 2 numbers in order in the range of 1-10

task1 g1 = new task1(a);

task2 g2 = new task2(a);

Thread t1 = new Thread(g1);

Thread t2 = new Thread(g2);

t1.start();

t2.start();

}

}

 

Write the classes artis, task1 and task2 accordingly.

 

Hint: You can pass the order between tasks by sleeping the thread connected to the task that is defending its order for 1 second. You do not need to use lock and condition constructs.

Expert Solution
steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
Linux
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education