33 lines
938 B
Java
33 lines
938 B
Java
package exercises.ex_s3;
|
|
|
|
import java.util.ArrayList;
|
|
import java.util.List;
|
|
|
|
public class TestingAtomicLong {
|
|
public static String[] names = {
|
|
"Alice", "Bob", "Charlie", "Derek", "Emily",
|
|
"Fionna", "Greg", "Harry", "Isabella", "Julia"
|
|
};
|
|
public static void main(String[] args) throws InterruptedException {
|
|
List<AbstractTweet> tweets = new ArrayList<>();
|
|
AbstractTweet tweet1 = new Tweet("Alice", "Java is cool !");
|
|
AbstractTweet tweet2 = new AtomicTweet("Bob", "ISC is the best !");
|
|
tweets.add(tweet1);
|
|
tweets.add(tweet2);
|
|
|
|
Thread[] users = new Thread[10];
|
|
|
|
for (int i = 0; i < 10; i++) {
|
|
users[i] = new Thread(new User(names[i], tweets));
|
|
users[i].start();
|
|
}
|
|
|
|
for (int i = 0; i < 10; i++) {
|
|
users[i].join();
|
|
}
|
|
|
|
System.out.println(tweet1);
|
|
System.out.println(tweet2);
|
|
}
|
|
}
|