This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package com.pig16; | |
| import javafx.animation.AnimationTimer; | |
| import javafx.animation.FillTransition; | |
| import javafx.animation.Timeline; | |
| import javafx.application.Application; | |
| import javafx.beans.value.ChangeListener; | |
| import javafx.event.EventHandler; | |
| import javafx.geometry.Pos; | |
| import javafx.scene.Scene; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package com.pig11; | |
| public class Main3 { | |
| public static void main(String[] args) { | |
| KeyObject keyObject =new KeyObject(); | |
| Thread threadA=new Thread(new RunnerA(keyObject)); | |
| Thread threadB=new Thread(new RunnerB(keyObject)); | |
| threadA.setName("Thread A"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package com.pig15; | |
| import java.util.Random; | |
| public class Main_deadlock_solu { | |
| public static void main(String[] args) { | |
| Intersection intersection=new Intersection(); | |
| Thread TrainAThread =new Thread(new TrainA(intersection)); | |
| Thread TrainBThread =new Thread(new TrainB(intersection)); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package com.pig15; | |
| import java.util.Random; | |
| public class Main { | |
| public static void main(String[] args) { | |
| Intersection intersection=new Intersection(); | |
| Thread TrainAThread =new Thread(new TrainA(intersection)); | |
| Thread TrainBThread =new Thread(new TrainB(intersection)); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package com.pig14; | |
| public class Main { | |
| public static void main(String[] args) { | |
| SharedClass sharedClass = new SharedClass(); | |
| Thread thread1 = new Thread(() -> { | |
| for (int i = 0; i < Integer.MAX_VALUE; i++) { | |
| sharedClass.increment(); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package com.pig14; | |
| public class Main { | |
| public static void main(String[] args) { | |
| SharedClass sharedClass = new SharedClass(); | |
| Thread thread1 = new Thread(() -> { | |
| for (int i = 0; i < Integer.MAX_VALUE; i++) { | |
| sharedClass.increment(); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package com.pig13; | |
| public class MinMaxMetrics { | |
| private volatile long min; | |
| private volatile long max; | |
| public MinMaxMetrics() { | |
| this.min=0; | |
| this.max=0; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class MinMaxMetrics { | |
| // Add all necessary member variables | |
| /** | |
| * Initializes all member variables | |
| */ | |
| public MinMaxMetrics() { | |
| // Add code here | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package com.pig12; | |
| import java.util.Random; | |
| public class Main { | |
| public static void main(String [] args) { | |
| Metrics metrics = new Metrics(); | |
| BusinessLogic businessLogicThread1 = new BusinessLogic(metrics); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class BusinessLogicClass { | |
| long stat = System.currentTimeMillis(); | |
| // important operation here | |
| long end = System.currentTimeMillis(); | |
| long duration = end - stat; | |
| captureSample(duration); | |
| } |