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 Main { | |
| public static void main(String[] args) throws InterruptedException { | |
| InventoryCounter inventoryCounter = new InventoryCounter(); | |
| IncrementingThread incrementingThread = new IncrementingThread(inventoryCounter); | |
| DecrementingThread decrementingThread = new DecrementingThread(inventoryCounter); | |
| incrementingThread.start(); |
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.pig10; | |
| public class Main { | |
| public static void main(String[] args) throws InterruptedException { | |
| InventoryCounter inventoryCounter = new InventoryCounter(); | |
| IncrementingThread incrementingThread = new IncrementingThread(inventoryCounter); | |
| DecrementingThread decrementingThread = new DecrementingThread(inventoryCounter); | |
| incrementingThread.start(); |
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.pig9; | |
| import java.io.IOException; | |
| import java.io.OutputStream; | |
| import java.net.InetSocketAddress; | |
| import java.nio.file.Files; | |
| import java.nio.file.Paths; | |
| import java.util.concurrent.Executor; | |
| import java.util.concurrent.Executors; |
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.pig8; | |
| import java.awt.image.BufferedImage; | |
| import java.io.File; | |
| import java.io.IOException; | |
| import javax.imageio.ImageIO; | |
| public class Main { |
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
| import java.math.BigInteger; | |
| public class ComplexCalculation { | |
| public BigInteger calculateResult(BigInteger base1, | |
| BigInteger power1, | |
| BigInteger base2, | |
| BigInteger power2) { | |
| BigInteger result; | |
| PowerCalculatingThread thread1 = new PowerCalculatingThread(base1, power1); | |
| PowerCalculatingThread thread2 = new PowerCalculatingThread(base2, power2); |
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 pig7; | |
| import java.math.BigInteger; | |
| import java.util.ArrayList; | |
| import java.util.List; | |
| public class ComplexCalculation { | |
| public BigInteger calculateResult(BigInteger base1, BigInteger power1, BigInteger base2, BigInteger power2) throws InterruptedException { | |
| BigInteger result; | |
| /* |
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
| import java.math.BigInteger; | |
| public class ComplexCalculation { | |
| public BigInteger calculateResult(BigInteger base1, BigInteger power1, BigInteger base2, BigInteger power2) { | |
| BigInteger result; | |
| /* | |
| Calculate result = ( base1 ^ power1 ) + (base2 ^ power2). | |
| Where each calculation in (..) is calculated on a different thread | |
| */ | |
| return result; |
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 pig6; | |
| import java.math.BigInteger; | |
| import java.util.ArrayList; | |
| import java.util.Arrays; | |
| import java.util.List; | |
| public class Main { | |
| public static void main(String[] args) throws InterruptedException { |
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 pig6; | |
| import java.math.BigInteger; | |
| import java.util.ArrayList; | |
| import java.util.Arrays; | |
| import java.util.List; | |
| public class Main { | |
| public static void main(String[] args) { |
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
| import java.util.ArrayList; | |
| import java.util.List; | |
| public class MultiExecutor { | |
| private final List<Runnable> tasks; | |
| /* | |
| * @param tasks to executed concurrently | |
| */ |