This project simulates a complex conflict resolution scenario involving multiple characters and their interactions across a multiverse. It demonstrates the use of Java threads and semaphores to manage concurrent actions and synchronization among various entities. This project is inspired by the 2022 movie Everything Everywhere All At Once ("Todo en Todas Partes al Mismo Tiempo [TTPMT]" in Spanish).
The Multiverse Conflict Simulation project uses Java's multithreading capabilities and semaphores to simulate the interactions and resolutions among different characters in a multiverse setting. The main class, ClimaxDesenlaceTTPMT
, orchestrates the simulation by creating and managing threads for each character, ensuring that the events occur in a synchronized and orderly manner.
- Multithreading: Utilizes Java's threading capabilities to manage concurrent tasks.
- Synchronization: Employs semaphores to coordinate actions among multiple characters.
- Simulation: Creates a realistic scenario of conflict resolution in a multiverse using print statements to represent the actions of each character.
- pom.xml: Maven configuration file that manages project dependencies and build settings.
- src/: Contains the source code and test code for the project.
- main/: Main application code.
- java/: Java source code directory.
- com/mycompany/climaxdesenlacettpmt/: Package directory containing all the Java classes for the project.
- ClimaxDesenlaceTTPMT.java: Entry point of the application; sets up and starts the threads for each character.
- com/mycompany/climaxdesenlacettpmt/: Package directory containing all the Java classes for the project.
- java/: Java source code directory.
- test/: Placeholder for test code.
- main/: Main application code.
- target/: Directory generated by Maven during the build process.
- classes/: Contains compiled bytecode of the Java classes.
- com/mycompany/climaxdesenlacettpmt/: Compiled classes for the project.
- ClimaxDesenlaceTTPMT.class: Compiled bytecode for the entry point class.
- Desenlace.class: Compiled bytecode for the Desenlace class.
- Evelyn.class: Compiled bytecode for the Evelyn class.
- JobuTupaki.class: Compiled bytecode for the Jobu Tupaki class.
- Multiverso.class: Compiled bytecode for the Multiverso class.
- Pelicula.class: Compiled bytecode for the Pelicula class.
- Waymond.class: Compiled bytecode for the Waymond class.
- com/mycompany/climaxdesenlacettpmt/: Compiled classes for the project.
- generated-sources/: Directory for generated sources (if any).
- annotations/: Placeholder for annotation processors.
- maven-status/: Directory containing Maven build status files.
- maven-compiler-plugin/compile/default-compile/: Contains lists of created and input files during compilation.
- createdFiles.lst: List of files created during the build.
- inputFiles.lst: List of files used as input during the build.
- maven-compiler-plugin/compile/default-compile/: Contains lists of created and input files during compilation.
- test-classes/: Directory for compiled test classes.
- classes/: Contains compiled bytecode of the Java classes.
This class is the entry point of the simulation. It creates semaphores and threads for each character, managing their interactions.
Main Method:
public static void main(String[] args) {
Semaphore semEvelyn = new Semaphore(1); // Semáforo para controlar a Evelyn
Semaphore semWaymond = new Semaphore(0); // Semáforo para controlar a Waymond
Semaphore semJobu = new Semaphore(0); // Semáforo para controlar a Jobu Tupaki
Semaphore semMultiverso = new Semaphore(0); // Semáforo para el multiverso
Semaphore semReparacion = new Semaphore(0); // Semáforo para las reparaciones
Evelyn evelyn = new Evelyn(semEvelyn, semWaymond, semJobu, semMultiverso, semReparacion);
Waymond waymond = new Waymond(semEvelyn, semWaymond, semJobu, semMultiverso, semReparacion);
JobuTupaki jobu = new JobuTupaki(semEvelyn, semWaymond, semJobu, semMultiverso, semReparacion);
Multiverso multiverso = new Multiverso(semEvelyn, semWaymond, semJobu, semMultiverso, semReparacion);
Desenlace desenlace = new Desenlace(semEvelyn, semWaymond, semJobu, semMultiverso, semReparacion);
Thread threadEvelyn = new Thread(evelyn);
Thread threadWaymond = new Thread(waymond);
Thread threadJobu = new Thread(jobu);
Thread threadMultiverso = new Thread(multiverso);
Thread threadDesenlace = new Thread(desenlace);
threadEvelyn.start();
threadWaymond.start();
threadJobu.start();
threadMultiverso.start();
threadDesenlace.start();
}
This class represents the character Evelyn. It uses semaphores to synchronize actions with other characters.
Run Method:
public void run() {
try {
// Clímax
System.out.println("Evelyn, Waymond, Joy y Gong Gong confrontan a Jobu Tupaki en su restaurante.");
semEvelyn.acquire();
semJobu.release(); //WAYMOND
System.out.println("Evelyn vence a Jobu Tupaki con el poder del amor.");
semMultiverso.release();
semReparacion.release();
} catch (InterruptedException e) {
e.printStackTrace();
}
}
This class represents the character Waymond. It uses semaphores to synchronize actions with other characters.
Run Method:
public void run() {
// Clímax
//semWaymond.acquire();
System.out.println("Waymond revela a Evelyn que solo ella puede detener a Jobu Tupaki.");
semJobu.release();
}
This class represents the character Jobu Tupaki. It uses semaphores to synchronize actions with other characters.
Run Method:
public void run() {
// Clímax
System.out.println("Jobu Tupaki amenaza con destruir el multiverso con una bola cósmica.");
semWaymond.release();
semEvelyn.release();
}
This class represents the multiverse. It uses semaphores to synchronize actions with other characters.
Run Method:
public void run() {
try {
// Clímax
semMultiverso.acquire();
System.out.println("El multiverso es salvado.");
semEvelyn.release();
} catch (InterruptedException e) {
e.printStackTrace();
}
}
This class represents the resolution of the conflict. It uses semaphores to synchronize actions with other characters.
Run Method:
public void run() {
try {
// Desenlace
semReparacion.acquire();
System.out.println("Evelyn regresa a su universo siendo más feliz y realizada.");
System.out.println("Evelyn repara su relación con su hija, Joy.");
System.out.println("Evelyn se reconcilia con su padre, Gong Gong.");
System.out.println("Evelyn abre una nueva lavandería con Waymond.");
System.out.println("Evelyn continúa explorando el multiverso.");
semEvelyn.release();
} catch (InterruptedException e) {
e.printStackTrace();
}
}
To run the simulation, compile the Java files and execute the ClimaxDesenlaceTTPMT
class.
- Java Development Kit (JDK)
- Maven for managing project dependencies
- An IDE or text editor for Java development
- Clone the repository.
- Navigate to the
src/main/java/com/mycompany/climaxdesenlacettpmt
directory. - Compile the Java files using Maven:
mvn compile
. - Run the simulation using:
mvn exec:java -Dexec.mainClass="com.mycompany.climaxdesenlacettpmt.ClimaxDesenlaceTTPMT"
.