Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package runners_judge;
- import javax.swing.*;
- public class Application
- {
- public static void main(String[] args)
- {
- Start s = null;
- Judge j = new Judge();
- int runners = 0;
- while(runners <= 0)
- {
- try
- {
- runners = Integer.parseInt(JOptionPane.showInputDialog(null, "Insert number of runners:"));
- if(runners >= 0)
- s = new Start(runners);
- }
- catch(NumberFormatException e)
- {
- JOptionPane.showMessageDialog(null, "Error: invalid number format");
- }
- }
- Thread t = new Thread(j);
- t.setDaemon(true);
- t.start();
- Thread[] threads = new Thread[runners];
- for(int i = 0; i < runners; i++)
- {
- Runner r = new Runner(i, s);
- threads[i] = new Thread(r);
- threads[i].start();
- }
- for(int i = 0; i < runners; i++)
- {
- try
- {
- threads[i].join();
- }
- catch(InterruptedException e)
- {
- e.printStackTrace();
- }
- }
- Judge.printChart();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement