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