SlideShare a Scribd company logo
1 of 4
Download to read offline
Código Fuente: (http://goo.gl/dFmzn2)
/************************************************************
* UNIVERSITARIA DE DESARROLLO E INVESTIGACIÓN - UDI *
* ============================== *
* GPL 2015 por Juan C. Garcia-Ojeda *
* Creado : Marzo 4 de 2015 *
* Modificado : Marzo 4 de 2015 *
* Estado : Actualizado *
* Archivo : WomenThread.java *
* Propósito : Solución problema propuesto en *
* http://www.slideshare.net/j.c.garciao/ejercicio-semaforo *
************************************************************/
package co.edu.udi.monitors;
public class WomenThread extends Thread {
String name = "";
String gender ="";
BanoMonitor bm;
public WomenThread(String name,
String gender,
BanoMonitor bm){
this.name=name;
this.gender=gender;
this.bm=bm;
}
public void run(){
while(true){
try {
bm.arrive(name,gender);
Thread.sleep(2500);
}
catch(InterruptedException e){
e.printStackTrace();
}
finally{
try {
bm.depart(name,gender);
Thread.sleep(2500);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
}
}
/************************************************************
* UNIVERSITARIA DE DESARROLLO E INVESTIGACIÓN - UDI *
* ============================== *
* GPL 2015 por Juan C. Garcia-Ojeda *
* Creado : Marzo 4 de 2015 *
* Modificado : Marzo 4 de 2015 *
* Estado : Actualizado *
* Archivo : MenThread.java *
* Propósito : Solución problema propuesto en *
* http://www.slideshare.net/j.c.garciao/ejercicio-semaforo *
************************************************************/
package co.edu.udi.monitors;
public class MenThread extends Thread {
String name = "";
String gender ="";
BanoMonitor bm;
public MenThread(String name, String gender, BanoMonitor bm){
this.name=name;
this.gender=gender;
this.bm=bm;
}
public void run(){
while(true){
try {
bm.arrive(name,gender);
Thread.sleep(2500);
}
catch(InterruptedException e){
// TODO Auto-generated catch block
e.printStackTrace();
}
finally{
try {
bm.depart(name,gender);
Thread.sleep(2500);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
}
}
/************************************************************
* UNIVERSITARIA DE DESARROLLO E INVESTIGACIÓN - UDI *
* ============================== *
* GPL 2015 por Juan C. Garcia-Ojeda *
* Creado : Marzo 4 de 2015 *
* Modificado : Marzo 4 de 2015 *
* Estado : Actualizado *
* Archivo : BanoMonitor.java *
* Propósito : Solución problema propuesto en *
* http://www.slideshare.net/j.c.garciao/ejercicio-semaforo *
************************************************************/
package co.edu.udi.monitors;
public class BanoMonitor {
protected int spaces;
protected int capacity;
protected String gender_monitor="";
public BanoMonitor(int n){
capacity = spaces = n;
}
synchronized void arrive(String persona,String gender)
throws InterruptedException {
while(spaces==0 ||
(spaces!=0 && gender_monitor.length()>0 &&
gender_monitor.compareTo(gender)!=0)) wait();
System.out.println("--> Arribo "+persona);
gender_monitor=gender;
--spaces;
System.out.println("Espacios Ocupados "+
(capacity-spaces));
notify();
}
synchronized void depart(String persona, String gender)
throws InterruptedException {
while (spaces==capacity) wait();
System.out.println("<-- Salio "+persona);
++spaces;
System.out.println("Espacios Disponibles "+(spaces));
if(spaces==capacity){
gender_monitor="";
System.out.println("/* */");
System.out.println("/*Baño Totalmente Vacio */");
System.out.println("/* */");
}
notify();
}
}
/************************************************************
* UNIVERSITARIA DE DESARROLLO E INVESTIGACIÓN - UDI *
* ============================== *
* GPL 2015 por Juan C. Garcia-Ojeda *
* Creado : Marzo 4 de 2015 *
* Modificado : Marzo 4 de 2015 *
* Estado : Actualizado *
* Archivo : Principal.java *
* Propósito : Solución problema propuesto en *
* http://www.slideshare.net/j.c.garciao/ejercicio-semaforo *
************************************************************/
package co.edu.udi.monitors;
public class Principal {
public static void main(String[] args) throws
InterruptedException {
BanoMonitor bm= new BanoMonitor(4);
System.out.println("Inicialización...");
new MenThread("Pedro","H",bm).start();
new MenThread("Luis","H",bm).start();
new MenThread("Jose","H",bm).start();
new MenThread("Juan","H",bm).start();
new MenThread("Pablo","H",bm).start();
new WomenThread("Ana","M",bm).start();
new WomenThread("Rosa","M",bm).start();
new WomenThread("Maria","M",bm).start();
new WomenThread("Julia","M",bm).start();
new WomenThread("Juana","M",bm).start();
/*new MenThread("Pedro","H",bm).start();
new WomenThread("Ana","M",bm).start();
new MenThread("Luis","H",bm).start();
new WomenThread("Rosa","M",bm).start();
new MenThread("Jose","H",bm).start();
new WomenThread("Maria","M",bm).start();
new MenThread("Juan","H",bm).start();
new WomenThread("Julia","M",bm).start();
new WomenThread("Juana","M",bm).start();
new MenThread("Pablo","H",bm).start();*/
}
}

More Related Content

What's hot

SPRING - MAVEN - REST API (ITA - Luglio 2017)
SPRING - MAVEN - REST API (ITA - Luglio 2017)SPRING - MAVEN - REST API (ITA - Luglio 2017)
SPRING - MAVEN - REST API (ITA - Luglio 2017)Valerio Radice
 
Instalación smoothwall v0.9
Instalación smoothwall v0.9Instalación smoothwall v0.9
Instalación smoothwall v0.9David Loor
 
In the DOM, no one will hear you scream
In the DOM, no one will hear you screamIn the DOM, no one will hear you scream
In the DOM, no one will hear you screamMario Heiderich
 
Introduction to Unit Testing with PHPUnit
Introduction to Unit Testing with PHPUnitIntroduction to Unit Testing with PHPUnit
Introduction to Unit Testing with PHPUnitMichelangelo van Dam
 
OWASP Mobile Security: Top 10 Risks for 2017
OWASP Mobile Security: Top 10 Risks for 2017OWASP Mobile Security: Top 10 Risks for 2017
OWASP Mobile Security: Top 10 Risks for 2017TecsyntSolutions
 
Android Hacking + Pentesting
Android Hacking + Pentesting Android Hacking + Pentesting
Android Hacking + Pentesting Sina Manavi
 
PHP-MySQL Database Connectivity Using XAMPP Server
PHP-MySQL Database Connectivity Using XAMPP ServerPHP-MySQL Database Connectivity Using XAMPP Server
PHP-MySQL Database Connectivity Using XAMPP ServerRajiv Bhatia
 
Introduction to Spring Boot!
Introduction to Spring Boot!Introduction to Spring Boot!
Introduction to Spring Boot!Jakub Kubrynski
 
[PHPConf Taiwan 2015] 跟著 Laravel 5.1 一起成為更好的 PHP 開發者
[PHPConf Taiwan 2015] 跟著 Laravel 5.1 一起成為更好的 PHP 開發者[PHPConf Taiwan 2015] 跟著 Laravel 5.1 一起成為更好的 PHP 開發者
[PHPConf Taiwan 2015] 跟著 Laravel 5.1 一起成為更好的 PHP 開發者Shengyou Fan
 
PHP unserialization vulnerabilities: What are we missing?
PHP unserialization vulnerabilities: What are we missing?PHP unserialization vulnerabilities: What are we missing?
PHP unserialization vulnerabilities: What are we missing?Sam Thomas
 
Asp.net state management
Asp.net state managementAsp.net state management
Asp.net state managementpriya Nithya
 
Grails Simple Login
Grails Simple LoginGrails Simple Login
Grails Simple Loginmoniguna
 
Lan chat system
Lan chat systemLan chat system
Lan chat systemWipro
 
Introduction to Node JS.pdf
Introduction to Node JS.pdfIntroduction to Node JS.pdf
Introduction to Node JS.pdfBareen Shaikh
 

What's hot (20)

PHP - Introduction to PHP Fundamentals
PHP -  Introduction to PHP FundamentalsPHP -  Introduction to PHP Fundamentals
PHP - Introduction to PHP Fundamentals
 
SPRING - MAVEN - REST API (ITA - Luglio 2017)
SPRING - MAVEN - REST API (ITA - Luglio 2017)SPRING - MAVEN - REST API (ITA - Luglio 2017)
SPRING - MAVEN - REST API (ITA - Luglio 2017)
 
Instalación smoothwall v0.9
Instalación smoothwall v0.9Instalación smoothwall v0.9
Instalación smoothwall v0.9
 
MSDN - ASP.NET MVC
MSDN - ASP.NET MVCMSDN - ASP.NET MVC
MSDN - ASP.NET MVC
 
In the DOM, no one will hear you scream
In the DOM, no one will hear you screamIn the DOM, no one will hear you scream
In the DOM, no one will hear you scream
 
Introduction to Unit Testing with PHPUnit
Introduction to Unit Testing with PHPUnitIntroduction to Unit Testing with PHPUnit
Introduction to Unit Testing with PHPUnit
 
Php
PhpPhp
Php
 
OWASP Mobile Security: Top 10 Risks for 2017
OWASP Mobile Security: Top 10 Risks for 2017OWASP Mobile Security: Top 10 Risks for 2017
OWASP Mobile Security: Top 10 Risks for 2017
 
Android Hacking + Pentesting
Android Hacking + Pentesting Android Hacking + Pentesting
Android Hacking + Pentesting
 
PHP-MySQL Database Connectivity Using XAMPP Server
PHP-MySQL Database Connectivity Using XAMPP ServerPHP-MySQL Database Connectivity Using XAMPP Server
PHP-MySQL Database Connectivity Using XAMPP Server
 
Introduction to Spring Boot!
Introduction to Spring Boot!Introduction to Spring Boot!
Introduction to Spring Boot!
 
[PHPConf Taiwan 2015] 跟著 Laravel 5.1 一起成為更好的 PHP 開發者
[PHPConf Taiwan 2015] 跟著 Laravel 5.1 一起成為更好的 PHP 開發者[PHPConf Taiwan 2015] 跟著 Laravel 5.1 一起成為更好的 PHP 開發者
[PHPConf Taiwan 2015] 跟著 Laravel 5.1 一起成為更好的 PHP 開發者
 
Presentacion git
Presentacion gitPresentacion git
Presentacion git
 
Sessions in php
Sessions in php Sessions in php
Sessions in php
 
PHP unserialization vulnerabilities: What are we missing?
PHP unserialization vulnerabilities: What are we missing?PHP unserialization vulnerabilities: What are we missing?
PHP unserialization vulnerabilities: What are we missing?
 
Asp.net state management
Asp.net state managementAsp.net state management
Asp.net state management
 
Grails Simple Login
Grails Simple LoginGrails Simple Login
Grails Simple Login
 
Lan chat system
Lan chat systemLan chat system
Lan chat system
 
Introduction to Node JS.pdf
Introduction to Node JS.pdfIntroduction to Node JS.pdf
Introduction to Node JS.pdf
 
Git and GitHub Info Session
Git and GitHub Info SessionGit and GitHub Info Session
Git and GitHub Info Session
 

Viewers also liked

A152 w0i9 inteligenciaartificial
A152 w0i9 inteligenciaartificialA152 w0i9 inteligenciaartificial
A152 w0i9 inteligenciaartificialjcbp_peru
 
Utp 2015-2_ia lab2
 Utp 2015-2_ia lab2 Utp 2015-2_ia lab2
Utp 2015-2_ia lab2jcbp_peru
 
Ia 2014 2 balotario de la pc1
Ia 2014 2 balotario de la pc1Ia 2014 2 balotario de la pc1
Ia 2014 2 balotario de la pc1c09271
 
Utp 2015-2_ia_lab1.pdf
 Utp 2015-2_ia_lab1.pdf Utp 2015-2_ia_lab1.pdf
Utp 2015-2_ia_lab1.pdfjcbp_peru
 
Woi9 ia 2015 1 balotario de la pc2
Woi9 ia 2015 1 balotario de la pc2Woi9 ia 2015 1 balotario de la pc2
Woi9 ia 2015 1 balotario de la pc2jcbp_peru
 
Utp 2015-1_ia_s1_introduccion ia
 Utp 2015-1_ia_s1_introduccion ia Utp 2015-1_ia_s1_introduccion ia
Utp 2015-1_ia_s1_introduccion iajcbp_peru
 
Utp 2015-2_ia_s2_intro a las rna
 Utp 2015-2_ia_s2_intro a las rna  Utp 2015-2_ia_s2_intro a las rna
Utp 2015-2_ia_s2_intro a las rna jcbp_peru
 
Utp 2015-2_ia_s4_red perceptron
 Utp 2015-2_ia_s4_red perceptron Utp 2015-2_ia_s4_red perceptron
Utp 2015-2_ia_s4_red perceptronjcbp_peru
 
Utp 2015-2_ia_s3_aprendizaje automatico
 Utp 2015-2_ia_s3_aprendizaje automatico Utp 2015-2_ia_s3_aprendizaje automatico
Utp 2015-2_ia_s3_aprendizaje automaticojcbp_peru
 
Utp ia_2015-1_s11-12_logica difusa y conjuntos difusos
 Utp ia_2015-1_s11-12_logica difusa y conjuntos difusos Utp ia_2015-1_s11-12_logica difusa y conjuntos difusos
Utp ia_2015-1_s11-12_logica difusa y conjuntos difusosjcbp_peru
 
Utp 2015-2_ia_s6_adaline y backpropagation
 Utp 2015-2_ia_s6_adaline y backpropagation Utp 2015-2_ia_s6_adaline y backpropagation
Utp 2015-2_ia_s6_adaline y backpropagationjcbp_peru
 
Utp ia_2014-2_s10_redes de funciones de base radial
 Utp ia_2014-2_s10_redes de funciones de base radial Utp ia_2014-2_s10_redes de funciones de base radial
Utp ia_2014-2_s10_redes de funciones de base radialjcbp_peru
 
Utp ia_2015-2_s89_redes autorganizadas
 Utp ia_2015-2_s89_redes autorganizadas Utp ia_2015-2_s89_redes autorganizadas
Utp ia_2015-2_s89_redes autorganizadasjcbp_peru
 
Utp sirn_s13_sistemas de control basados en logic difusa
 Utp sirn_s13_sistemas de control basados en logic difusa Utp sirn_s13_sistemas de control basados en logic difusa
Utp sirn_s13_sistemas de control basados en logic difusajcbp_peru
 
Procesamiento digital de señales con matlab
Procesamiento digital de señales con matlabProcesamiento digital de señales con matlab
Procesamiento digital de señales con matlabPercy Julio Chambi Pacco
 

Viewers also liked (18)

Exercicio k means
Exercicio k meansExercicio k means
Exercicio k means
 
Relajacion lagrangiana
Relajacion lagrangianaRelajacion lagrangiana
Relajacion lagrangiana
 
A152 w0i9 inteligenciaartificial
A152 w0i9 inteligenciaartificialA152 w0i9 inteligenciaartificial
A152 w0i9 inteligenciaartificial
 
Utp 2015-2_ia lab2
 Utp 2015-2_ia lab2 Utp 2015-2_ia lab2
Utp 2015-2_ia lab2
 
Ia 2014 2 balotario de la pc1
Ia 2014 2 balotario de la pc1Ia 2014 2 balotario de la pc1
Ia 2014 2 balotario de la pc1
 
Utp 2015-2_ia_lab1.pdf
 Utp 2015-2_ia_lab1.pdf Utp 2015-2_ia_lab1.pdf
Utp 2015-2_ia_lab1.pdf
 
Woi9 ia 2015 1 balotario de la pc2
Woi9 ia 2015 1 balotario de la pc2Woi9 ia 2015 1 balotario de la pc2
Woi9 ia 2015 1 balotario de la pc2
 
Utp 2015-1_ia_s1_introduccion ia
 Utp 2015-1_ia_s1_introduccion ia Utp 2015-1_ia_s1_introduccion ia
Utp 2015-1_ia_s1_introduccion ia
 
Utp 2015-2_ia_lab3
 Utp 2015-2_ia_lab3 Utp 2015-2_ia_lab3
Utp 2015-2_ia_lab3
 
Utp 2015-2_ia_s2_intro a las rna
 Utp 2015-2_ia_s2_intro a las rna  Utp 2015-2_ia_s2_intro a las rna
Utp 2015-2_ia_s2_intro a las rna
 
Utp 2015-2_ia_s4_red perceptron
 Utp 2015-2_ia_s4_red perceptron Utp 2015-2_ia_s4_red perceptron
Utp 2015-2_ia_s4_red perceptron
 
Utp 2015-2_ia_s3_aprendizaje automatico
 Utp 2015-2_ia_s3_aprendizaje automatico Utp 2015-2_ia_s3_aprendizaje automatico
Utp 2015-2_ia_s3_aprendizaje automatico
 
Utp ia_2015-1_s11-12_logica difusa y conjuntos difusos
 Utp ia_2015-1_s11-12_logica difusa y conjuntos difusos Utp ia_2015-1_s11-12_logica difusa y conjuntos difusos
Utp ia_2015-1_s11-12_logica difusa y conjuntos difusos
 
Utp 2015-2_ia_s6_adaline y backpropagation
 Utp 2015-2_ia_s6_adaline y backpropagation Utp 2015-2_ia_s6_adaline y backpropagation
Utp 2015-2_ia_s6_adaline y backpropagation
 
Utp ia_2014-2_s10_redes de funciones de base radial
 Utp ia_2014-2_s10_redes de funciones de base radial Utp ia_2014-2_s10_redes de funciones de base radial
Utp ia_2014-2_s10_redes de funciones de base radial
 
Utp ia_2015-2_s89_redes autorganizadas
 Utp ia_2015-2_s89_redes autorganizadas Utp ia_2015-2_s89_redes autorganizadas
Utp ia_2015-2_s89_redes autorganizadas
 
Utp sirn_s13_sistemas de control basados en logic difusa
 Utp sirn_s13_sistemas de control basados en logic difusa Utp sirn_s13_sistemas de control basados en logic difusa
Utp sirn_s13_sistemas de control basados en logic difusa
 
Procesamiento digital de señales con matlab
Procesamiento digital de señales con matlabProcesamiento digital de señales con matlab
Procesamiento digital de señales con matlab
 

Similar to Solucion bano unisex

computer project on shopping mall..cbse 2017-2018 project
computer project on shopping mall..cbse 2017-2018 projectcomputer project on shopping mall..cbse 2017-2018 project
computer project on shopping mall..cbse 2017-2018 projectRóhït Ràút
 
Treatment, Architecture and Threads
Treatment, Architecture and ThreadsTreatment, Architecture and Threads
Treatment, Architecture and ThreadsMathias Seguy
 
Commenting in Agile Development
Commenting in Agile DevelopmentCommenting in Agile Development
Commenting in Agile DevelopmentJan Rybák Benetka
 
Audit Technique SEO : les principales étapes à mettre en place
Audit Technique SEO : les principales étapes à mettre en placeAudit Technique SEO : les principales étapes à mettre en place
Audit Technique SEO : les principales étapes à mettre en placeSemrush France
 
Open social 2.0 sandbox ee and breaking out of the gadget box
Open social 2.0 sandbox  ee and breaking out of the gadget boxOpen social 2.0 sandbox  ee and breaking out of the gadget box
Open social 2.0 sandbox ee and breaking out of the gadget boxRyan Baxter
 
TipCalculatorProjectApp.gitignore.iml.gradlelocal.pro.docx
TipCalculatorProjectApp.gitignore.iml.gradlelocal.pro.docxTipCalculatorProjectApp.gitignore.iml.gradlelocal.pro.docx
TipCalculatorProjectApp.gitignore.iml.gradlelocal.pro.docxherthalearmont
 
Alcohol Awareness Special Lecture ReflectionAlcohol is among the.docx
Alcohol Awareness Special Lecture ReflectionAlcohol is among the.docxAlcohol Awareness Special Lecture ReflectionAlcohol is among the.docx
Alcohol Awareness Special Lecture ReflectionAlcohol is among the.docxsimonlbentley59018
 
Stefan Marsiske - What would hackers use? part1
Stefan Marsiske - What would hackers use? part1Stefan Marsiske - What would hackers use? part1
Stefan Marsiske - What would hackers use? part1ecommerce poland expo
 
[Droidcon Paris 2013]Multi-Versioning Android Tips
[Droidcon Paris 2013]Multi-Versioning Android Tips[Droidcon Paris 2013]Multi-Versioning Android Tips
[Droidcon Paris 2013]Multi-Versioning Android TipsKenichi Kambara
 
Cần gì đồ chùa khi chúng ta có những thứ tuyệt vời thế này
Cần gì đồ chùa khi chúng ta có những thứ tuyệt vời thế nàyCần gì đồ chùa khi chúng ta có những thứ tuyệt vời thế này
Cần gì đồ chùa khi chúng ta có những thứ tuyệt vời thế nàylaonap166
 
Exception handling
Exception handlingException handling
Exception handlingAkash gupta
 
With a little help from my friends: Handy MongoDB Tools
With a little help from my friends: Handy MongoDB ToolsWith a little help from my friends: Handy MongoDB Tools
With a little help from my friends: Handy MongoDB ToolsStennie Steneker
 
Open source projects with python
Open source projects with pythonOpen source projects with python
Open source projects with pythonroskakori
 
JSUG - Spring by Christoph Pickl
JSUG - Spring by Christoph PicklJSUG - Spring by Christoph Pickl
JSUG - Spring by Christoph PicklChristoph Pickl
 

Similar to Solucion bano unisex (20)

computer project on shopping mall..cbse 2017-2018 project
computer project on shopping mall..cbse 2017-2018 projectcomputer project on shopping mall..cbse 2017-2018 project
computer project on shopping mall..cbse 2017-2018 project
 
Treatment, Architecture and Threads
Treatment, Architecture and ThreadsTreatment, Architecture and Threads
Treatment, Architecture and Threads
 
Commenting in Agile Development
Commenting in Agile DevelopmentCommenting in Agile Development
Commenting in Agile Development
 
Durgesh
DurgeshDurgesh
Durgesh
 
Audit Technique SEO : les principales étapes à mettre en place
Audit Technique SEO : les principales étapes à mettre en placeAudit Technique SEO : les principales étapes à mettre en place
Audit Technique SEO : les principales étapes à mettre en place
 
Unit test
Unit testUnit test
Unit test
 
Supermarket
SupermarketSupermarket
Supermarket
 
Open social 2.0 sandbox ee and breaking out of the gadget box
Open social 2.0 sandbox  ee and breaking out of the gadget boxOpen social 2.0 sandbox  ee and breaking out of the gadget box
Open social 2.0 sandbox ee and breaking out of the gadget box
 
Http xayaguud
Http xayaguudHttp xayaguud
Http xayaguud
 
TipCalculatorProjectApp.gitignore.iml.gradlelocal.pro.docx
TipCalculatorProjectApp.gitignore.iml.gradlelocal.pro.docxTipCalculatorProjectApp.gitignore.iml.gradlelocal.pro.docx
TipCalculatorProjectApp.gitignore.iml.gradlelocal.pro.docx
 
Alcohol Awareness Special Lecture ReflectionAlcohol is among the.docx
Alcohol Awareness Special Lecture ReflectionAlcohol is among the.docxAlcohol Awareness Special Lecture ReflectionAlcohol is among the.docx
Alcohol Awareness Special Lecture ReflectionAlcohol is among the.docx
 
Stefan Marsiske - What would hackers use? part1
Stefan Marsiske - What would hackers use? part1Stefan Marsiske - What would hackers use? part1
Stefan Marsiske - What would hackers use? part1
 
[Droidcon Paris 2013]Multi-Versioning Android Tips
[Droidcon Paris 2013]Multi-Versioning Android Tips[Droidcon Paris 2013]Multi-Versioning Android Tips
[Droidcon Paris 2013]Multi-Versioning Android Tips
 
Cần gì đồ chùa khi chúng ta có những thứ tuyệt vời thế này
Cần gì đồ chùa khi chúng ta có những thứ tuyệt vời thế nàyCần gì đồ chùa khi chúng ta có những thứ tuyệt vời thế này
Cần gì đồ chùa khi chúng ta có những thứ tuyệt vời thế này
 
Computer
ComputerComputer
Computer
 
Exception handling
Exception handlingException handling
Exception handling
 
With a little help from my friends: Handy MongoDB Tools
With a little help from my friends: Handy MongoDB ToolsWith a little help from my friends: Handy MongoDB Tools
With a little help from my friends: Handy MongoDB Tools
 
Open source projects with python
Open source projects with pythonOpen source projects with python
Open source projects with python
 
All you need is...Mezzanine!
All you need is...Mezzanine!All you need is...Mezzanine!
All you need is...Mezzanine!
 
JSUG - Spring by Christoph Pickl
JSUG - Spring by Christoph PicklJSUG - Spring by Christoph Pickl
JSUG - Spring by Christoph Pickl
 

More from Juan Carlos García Ojeda (12)

Enlace esteganografia
Enlace esteganografiaEnlace esteganografia
Enlace esteganografia
 
Discrecional Aprendizaje de Máquin Cádula Impar
Discrecional Aprendizaje de Máquin Cádula ImparDiscrecional Aprendizaje de Máquin Cádula Impar
Discrecional Aprendizaje de Máquin Cádula Impar
 
Discrecional Aprendizaje de Máquinas Cedula Par
Discrecional Aprendizaje de Máquinas Cedula ParDiscrecional Aprendizaje de Máquinas Cedula Par
Discrecional Aprendizaje de Máquinas Cedula Par
 
Segundo parcialsimulacro
Segundo parcialsimulacroSegundo parcialsimulacro
Segundo parcialsimulacro
 
Taller Aprendizaje M´squina
Taller Aprendizaje M´squinaTaller Aprendizaje M´squina
Taller Aprendizaje M´squina
 
Ejercicio sincronización
Ejercicio sincronizaciónEjercicio sincronización
Ejercicio sincronización
 
Sistemas Multiagente
Sistemas MultiagenteSistemas Multiagente
Sistemas Multiagente
 
Hilos semaforos
Hilos semaforosHilos semaforos
Hilos semaforos
 
Ejercicio ID3 Datos Numericos
Ejercicio ID3 Datos NumericosEjercicio ID3 Datos Numericos
Ejercicio ID3 Datos Numericos
 
Mineríade datos
Mineríade datosMineríade datos
Mineríade datos
 
Planning Evacuation Routes with the P-graph Framework
Planning Evacuation Routes with the P-graph FrameworkPlanning Evacuation Routes with the P-graph Framework
Planning Evacuation Routes with the P-graph Framework
 
1. introducción a Agentes
1. introducción a Agentes1. introducción a Agentes
1. introducción a Agentes
 

Recently uploaded

Work-Permit-Receiver-in-Saudi-Aramco.pptx
Work-Permit-Receiver-in-Saudi-Aramco.pptxWork-Permit-Receiver-in-Saudi-Aramco.pptx
Work-Permit-Receiver-in-Saudi-Aramco.pptxJuliansyahHarahap1
 
Introduction to Serverless with AWS Lambda
Introduction to Serverless with AWS LambdaIntroduction to Serverless with AWS Lambda
Introduction to Serverless with AWS LambdaOmar Fathy
 
UNIT - IV - Air Compressors and its Performance
UNIT - IV - Air Compressors and its PerformanceUNIT - IV - Air Compressors and its Performance
UNIT - IV - Air Compressors and its Performancesivaprakash250
 
Hazard Identification (HAZID) vs. Hazard and Operability (HAZOP): A Comparati...
Hazard Identification (HAZID) vs. Hazard and Operability (HAZOP): A Comparati...Hazard Identification (HAZID) vs. Hazard and Operability (HAZOP): A Comparati...
Hazard Identification (HAZID) vs. Hazard and Operability (HAZOP): A Comparati...soginsider
 
notes on Evolution Of Analytic Scalability.ppt
notes on Evolution Of Analytic Scalability.pptnotes on Evolution Of Analytic Scalability.ppt
notes on Evolution Of Analytic Scalability.pptMsecMca
 
Call Girls Wakad Call Me 7737669865 Budget Friendly No Advance Booking
Call Girls Wakad Call Me 7737669865 Budget Friendly No Advance BookingCall Girls Wakad Call Me 7737669865 Budget Friendly No Advance Booking
Call Girls Wakad Call Me 7737669865 Budget Friendly No Advance Bookingroncy bisnoi
 
Unit 1 - Soil Classification and Compaction.pdf
Unit 1 - Soil Classification and Compaction.pdfUnit 1 - Soil Classification and Compaction.pdf
Unit 1 - Soil Classification and Compaction.pdfRagavanV2
 
Double Revolving field theory-how the rotor develops torque
Double Revolving field theory-how the rotor develops torqueDouble Revolving field theory-how the rotor develops torque
Double Revolving field theory-how the rotor develops torqueBhangaleSonal
 
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756dollysharma2066
 
Unleashing the Power of the SORA AI lastest leap
Unleashing the Power of the SORA AI lastest leapUnleashing the Power of the SORA AI lastest leap
Unleashing the Power of the SORA AI lastest leapRishantSharmaFr
 
COST-EFFETIVE and Energy Efficient BUILDINGS ptx
COST-EFFETIVE  and Energy Efficient BUILDINGS ptxCOST-EFFETIVE  and Energy Efficient BUILDINGS ptx
COST-EFFETIVE and Energy Efficient BUILDINGS ptxJIT KUMAR GUPTA
 
Design For Accessibility: Getting it right from the start
Design For Accessibility: Getting it right from the startDesign For Accessibility: Getting it right from the start
Design For Accessibility: Getting it right from the startQuintin Balsdon
 
chapter 5.pptx: drainage and irrigation engineering
chapter 5.pptx: drainage and irrigation engineeringchapter 5.pptx: drainage and irrigation engineering
chapter 5.pptx: drainage and irrigation engineeringmulugeta48
 

Recently uploaded (20)

Work-Permit-Receiver-in-Saudi-Aramco.pptx
Work-Permit-Receiver-in-Saudi-Aramco.pptxWork-Permit-Receiver-in-Saudi-Aramco.pptx
Work-Permit-Receiver-in-Saudi-Aramco.pptx
 
Introduction to Serverless with AWS Lambda
Introduction to Serverless with AWS LambdaIntroduction to Serverless with AWS Lambda
Introduction to Serverless with AWS Lambda
 
UNIT - IV - Air Compressors and its Performance
UNIT - IV - Air Compressors and its PerformanceUNIT - IV - Air Compressors and its Performance
UNIT - IV - Air Compressors and its Performance
 
Hazard Identification (HAZID) vs. Hazard and Operability (HAZOP): A Comparati...
Hazard Identification (HAZID) vs. Hazard and Operability (HAZOP): A Comparati...Hazard Identification (HAZID) vs. Hazard and Operability (HAZOP): A Comparati...
Hazard Identification (HAZID) vs. Hazard and Operability (HAZOP): A Comparati...
 
Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak HamilCara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
 
Call Girls in Netaji Nagar, Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
Call Girls in Netaji Nagar, Delhi 💯 Call Us 🔝9953056974 🔝 Escort ServiceCall Girls in Netaji Nagar, Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
Call Girls in Netaji Nagar, Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
 
(INDIRA) Call Girl Bhosari Call Now 8617697112 Bhosari Escorts 24x7
(INDIRA) Call Girl Bhosari Call Now 8617697112 Bhosari Escorts 24x7(INDIRA) Call Girl Bhosari Call Now 8617697112 Bhosari Escorts 24x7
(INDIRA) Call Girl Bhosari Call Now 8617697112 Bhosari Escorts 24x7
 
notes on Evolution Of Analytic Scalability.ppt
notes on Evolution Of Analytic Scalability.pptnotes on Evolution Of Analytic Scalability.ppt
notes on Evolution Of Analytic Scalability.ppt
 
(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7
(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7
(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7
 
Call Girls Wakad Call Me 7737669865 Budget Friendly No Advance Booking
Call Girls Wakad Call Me 7737669865 Budget Friendly No Advance BookingCall Girls Wakad Call Me 7737669865 Budget Friendly No Advance Booking
Call Girls Wakad Call Me 7737669865 Budget Friendly No Advance Booking
 
Water Industry Process Automation & Control Monthly - April 2024
Water Industry Process Automation & Control Monthly - April 2024Water Industry Process Automation & Control Monthly - April 2024
Water Industry Process Automation & Control Monthly - April 2024
 
Unit 1 - Soil Classification and Compaction.pdf
Unit 1 - Soil Classification and Compaction.pdfUnit 1 - Soil Classification and Compaction.pdf
Unit 1 - Soil Classification and Compaction.pdf
 
FEA Based Level 3 Assessment of Deformed Tanks with Fluid Induced Loads
FEA Based Level 3 Assessment of Deformed Tanks with Fluid Induced LoadsFEA Based Level 3 Assessment of Deformed Tanks with Fluid Induced Loads
FEA Based Level 3 Assessment of Deformed Tanks with Fluid Induced Loads
 
Double Revolving field theory-how the rotor develops torque
Double Revolving field theory-how the rotor develops torqueDouble Revolving field theory-how the rotor develops torque
Double Revolving field theory-how the rotor develops torque
 
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
 
Unleashing the Power of the SORA AI lastest leap
Unleashing the Power of the SORA AI lastest leapUnleashing the Power of the SORA AI lastest leap
Unleashing the Power of the SORA AI lastest leap
 
COST-EFFETIVE and Energy Efficient BUILDINGS ptx
COST-EFFETIVE  and Energy Efficient BUILDINGS ptxCOST-EFFETIVE  and Energy Efficient BUILDINGS ptx
COST-EFFETIVE and Energy Efficient BUILDINGS ptx
 
Design For Accessibility: Getting it right from the start
Design For Accessibility: Getting it right from the startDesign For Accessibility: Getting it right from the start
Design For Accessibility: Getting it right from the start
 
chapter 5.pptx: drainage and irrigation engineering
chapter 5.pptx: drainage and irrigation engineeringchapter 5.pptx: drainage and irrigation engineering
chapter 5.pptx: drainage and irrigation engineering
 
Integrated Test Rig For HTFE-25 - Neometrix
Integrated Test Rig For HTFE-25 - NeometrixIntegrated Test Rig For HTFE-25 - Neometrix
Integrated Test Rig For HTFE-25 - Neometrix
 

Solucion bano unisex

  • 1. Código Fuente: (http://goo.gl/dFmzn2) /************************************************************ * UNIVERSITARIA DE DESARROLLO E INVESTIGACIÓN - UDI * * ============================== * * GPL 2015 por Juan C. Garcia-Ojeda * * Creado : Marzo 4 de 2015 * * Modificado : Marzo 4 de 2015 * * Estado : Actualizado * * Archivo : WomenThread.java * * Propósito : Solución problema propuesto en * * http://www.slideshare.net/j.c.garciao/ejercicio-semaforo * ************************************************************/ package co.edu.udi.monitors; public class WomenThread extends Thread { String name = ""; String gender =""; BanoMonitor bm; public WomenThread(String name, String gender, BanoMonitor bm){ this.name=name; this.gender=gender; this.bm=bm; } public void run(){ while(true){ try { bm.arrive(name,gender); Thread.sleep(2500); } catch(InterruptedException e){ e.printStackTrace(); } finally{ try { bm.depart(name,gender); Thread.sleep(2500); } catch (InterruptedException e) { e.printStackTrace(); } } } } }
  • 2. /************************************************************ * UNIVERSITARIA DE DESARROLLO E INVESTIGACIÓN - UDI * * ============================== * * GPL 2015 por Juan C. Garcia-Ojeda * * Creado : Marzo 4 de 2015 * * Modificado : Marzo 4 de 2015 * * Estado : Actualizado * * Archivo : MenThread.java * * Propósito : Solución problema propuesto en * * http://www.slideshare.net/j.c.garciao/ejercicio-semaforo * ************************************************************/ package co.edu.udi.monitors; public class MenThread extends Thread { String name = ""; String gender =""; BanoMonitor bm; public MenThread(String name, String gender, BanoMonitor bm){ this.name=name; this.gender=gender; this.bm=bm; } public void run(){ while(true){ try { bm.arrive(name,gender); Thread.sleep(2500); } catch(InterruptedException e){ // TODO Auto-generated catch block e.printStackTrace(); } finally{ try { bm.depart(name,gender); Thread.sleep(2500); } catch (InterruptedException e) { // TODO Auto-generated catch block e.printStackTrace(); } } } } }
  • 3. /************************************************************ * UNIVERSITARIA DE DESARROLLO E INVESTIGACIÓN - UDI * * ============================== * * GPL 2015 por Juan C. Garcia-Ojeda * * Creado : Marzo 4 de 2015 * * Modificado : Marzo 4 de 2015 * * Estado : Actualizado * * Archivo : BanoMonitor.java * * Propósito : Solución problema propuesto en * * http://www.slideshare.net/j.c.garciao/ejercicio-semaforo * ************************************************************/ package co.edu.udi.monitors; public class BanoMonitor { protected int spaces; protected int capacity; protected String gender_monitor=""; public BanoMonitor(int n){ capacity = spaces = n; } synchronized void arrive(String persona,String gender) throws InterruptedException { while(spaces==0 || (spaces!=0 && gender_monitor.length()>0 && gender_monitor.compareTo(gender)!=0)) wait(); System.out.println("--> Arribo "+persona); gender_monitor=gender; --spaces; System.out.println("Espacios Ocupados "+ (capacity-spaces)); notify(); } synchronized void depart(String persona, String gender) throws InterruptedException { while (spaces==capacity) wait(); System.out.println("<-- Salio "+persona); ++spaces; System.out.println("Espacios Disponibles "+(spaces)); if(spaces==capacity){ gender_monitor=""; System.out.println("/* */"); System.out.println("/*Baño Totalmente Vacio */"); System.out.println("/* */"); } notify(); } }
  • 4. /************************************************************ * UNIVERSITARIA DE DESARROLLO E INVESTIGACIÓN - UDI * * ============================== * * GPL 2015 por Juan C. Garcia-Ojeda * * Creado : Marzo 4 de 2015 * * Modificado : Marzo 4 de 2015 * * Estado : Actualizado * * Archivo : Principal.java * * Propósito : Solución problema propuesto en * * http://www.slideshare.net/j.c.garciao/ejercicio-semaforo * ************************************************************/ package co.edu.udi.monitors; public class Principal { public static void main(String[] args) throws InterruptedException { BanoMonitor bm= new BanoMonitor(4); System.out.println("Inicialización..."); new MenThread("Pedro","H",bm).start(); new MenThread("Luis","H",bm).start(); new MenThread("Jose","H",bm).start(); new MenThread("Juan","H",bm).start(); new MenThread("Pablo","H",bm).start(); new WomenThread("Ana","M",bm).start(); new WomenThread("Rosa","M",bm).start(); new WomenThread("Maria","M",bm).start(); new WomenThread("Julia","M",bm).start(); new WomenThread("Juana","M",bm).start(); /*new MenThread("Pedro","H",bm).start(); new WomenThread("Ana","M",bm).start(); new MenThread("Luis","H",bm).start(); new WomenThread("Rosa","M",bm).start(); new MenThread("Jose","H",bm).start(); new WomenThread("Maria","M",bm).start(); new MenThread("Juan","H",bm).start(); new WomenThread("Julia","M",bm).start(); new WomenThread("Juana","M",bm).start(); new MenThread("Pablo","H",bm).start();*/ } }