Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class App {
- public static void main(String[] args) throws InterruptedException {
- System.out.println("Starting ...");
- Thread t1 = new Thread(new Runnable() {
- public void run() {
- Random random = new Random();
- for (int i = 0; i < 1E7; i++) {
- try {
- Thread.sleep(1);
- } catch (InterruptedException ex) {
- System.out.println("Interrupted Exception!");
- break;
- }
- Math.sin(random.nextInt());
- }
- }
- });
- t1.start();
- Thread.sleep(500);
- t1.interrupt();
- t1.join();
- System.out.println("Finished.");
- }
- }
Add Comment
Please, Sign In to add comment