From 96b3de4226194943ee749e4091b866ef22ce27ab Mon Sep 17 00:00:00 2001 From: Alexis DRAI Date: Thu, 26 Jan 2023 14:30:17 +0100 Subject: [PATCH] TP3_1_C --- src/GetStatus.java | 42 ++++++++++++++++++++++++++++++++++++++++++ src/IntWrapper.java | 1 + src/Main.java | 5 ----- 3 files changed, 43 insertions(+), 5 deletions(-) create mode 100644 src/GetStatus.java delete mode 100644 src/Main.java diff --git a/src/GetStatus.java b/src/GetStatus.java new file mode 100644 index 0000000..5b6b7fd --- /dev/null +++ b/src/GetStatus.java @@ -0,0 +1,42 @@ +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; + +public class GetStatus { + + private static final String[] hostList = { + "http://crunchify.com", + "http://yahoo.com", + "http://www.ebay.com", + "http://google.com", + "http://www.example.co", + "https://paypal.com", + "http://bing.com/", + "http://techcrunch.com/", + "http://mashable.com/", + "http://thenextweb.com/", + "http://wordpress.com/", + "http://wordpress.org/", + "http://example.com/", + "http://sjsu.edu/", + "http://ebay.co.uk/", + "http://google.co.uk/", + "http://www.wikipedia.org/", + "http://en.wikipedia.org/wiki/Main_Page" + }; + + private static final ExecutorService es = Executors.newFixedThreadPool(12); + + public static void main(String[] args) { + + IntWrapper[] codes = new IntWrapper[hostList.length]; + + for (int i = 0; i < hostList.length; ++i) { + IntWrapper code = new IntWrapper(); + codes[i] = code; + es.execute(new WebVerif(hostList[i], code)); + } + + es.shutdown(); + } + +} diff --git a/src/IntWrapper.java b/src/IntWrapper.java index f70e16a..6a97a88 100644 --- a/src/IntWrapper.java +++ b/src/IntWrapper.java @@ -4,6 +4,7 @@ public class IntWrapper { private int value; public IntWrapper(int value) {this.value = value;} + public IntWrapper() {this(-1);} public int getValue() {return value;} public void setValue(int value) {this.value = value;} } diff --git a/src/Main.java b/src/Main.java deleted file mode 100644 index 3c83272..0000000 --- a/src/Main.java +++ /dev/null @@ -1,5 +0,0 @@ -public class Main { - public static void main(String[] args) { - System.out.println("Hi"); - } -}