Archives
Trending
Support
Login
clear text
XML
Django
JavaScript
MATLAB
C
C++
C#
Python
SQL
Shell
Bash
Markdown
YAML
JSON
HTML
CSS
PHP
Java
Ruby
Go
Rust
Swift
Kotlin
Arduino
TypeScript
Perl
Autohotkey
Lua
SQF
R
Scala
Haskell
Groovy
Dart
Clojure
VB.NET
Objective-C
PowerShell
Bash
CoffeeScript
Verilog
public class ProductorFactura extends Thread{ private ArrayList
mostrador; private int num; private String[] types; private String type; private Random random; public ProductorFactura(ArrayList
mostrador) { this.mostrador=mostrador; this.num=0; this.types=new String[]{"con chocolate","simple","con coco"}; this.type=""; this.random=new Random(); } public void run() { while(true) { try { int timeProduction=random.nextInt(1300-1000)+1000; int typeRandom=random.nextInt(this.types.length); Thread.sleep(timeProduction); synchronized(mostrador) { this.num++; this.type=types[typeRandom]; Factura factura=new Factura(this.num,this.type); mostrador.add(factura); mostrador.notifyAll(); } }catch (InterruptedException e) { e.printStackTrace(); } System.out.println("Factura("+num+", "+this.type+")"+" en mostrador"); } } } public class ProductorBizcocho extends Thread{ private ArrayList
mostrador; private int num; private String[] types; private String type; private Random random; public ProductorBizcocho(ArrayList
mostrador) { this.mostrador=mostrador; this.num=0; this.types=new String[]{"Cuadrado","chato","relleno"}; this.type=""; this.random=new Random(); } public void run() { while(true) { try { int timeProduction=random.nextInt(600-400)+400; int typeRandom=random.nextInt(this.types.length); Thread.sleep(timeProduction); synchronized(mostrador) { this.num++; this.type=types[typeRandom]; Bizcocho bizcocho=new Bizcocho(this.num,this.type); mostrador.add(bizcocho); mostrador.notifyAll(); } }catch (InterruptedException e) { e.printStackTrace(); } System.out.println("Bizcocho("+this.num+", "+this.type+") en mostrador"); } } }
Mark as private (unlisted)
for 30 minutes
for 6 hours
for 1 day
for 1 week
for 1 month
for 1 year
everlasting (like CCCP)