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
import java.util.ArrayList; import java.util.List; import java.util.Random; import java.util.Scanner; import java.util.concurrent.Semaphore; public class Main { public static void main(String[] args) throws InterruptedException{ Factory f = new Factory(2); List
ls = new ArrayList<>(); for(int i = 0; i < 3; i++) { ls.add(new Thread(new Runnable() { @Override public void run() { Random rnd = new Random(); if(rnd.nextInt() % 2 == 0) { try { f.produce_vaccine(new String("v" + rnd.nextInt() % 10)); } catch (InterruptedException ex) { } } else { try { f.buy_vaccine(); } catch (InterruptedException ex) { } } } })); } for(int i = 0; i < 3; i++) { ls.get(i).start(); } for(int i =0; i < 3; i++) { try { ls.get(i).join(); } catch (InterruptedException ex) { } } } }
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)