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 Main { public static void main(String[] args) { ArrayList
lista=new ArrayList
(); Random random=new Random(); int tiempoInicial=100; int tiempoFinal=200; int consumidores=0; int productores=0; for(int i=0; i<20;i++) { int tiempoRetardo=random.nextInt((tiempoFinal-tiempoInicial)+1)+tiempoInicial; int prodCons=random.nextInt(2); // 0 o 1 try { Thread.sleep(tiempoRetardo); } catch (InterruptedException e) { e.printStackTrace(); } if(prodCons==0 && consumidores<10) { Consumidor consumidorX=new Consumidor(lista,consumidores); consumidorX.start(); consumidores++; } else if(prodCons==1 && productores<10) { Productor productorX=new Productor(lista,productores); productorX.start(); productores++; } } } }
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)