MainClass.java Source code

Java tutorial

Introduction

Here is the source code for MainClass.java

Source

public class MainClass {
    public static void main(String[] args) {
        Thread thread = new Thread(new MyThread());
        thread.setUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() {
            public void uncaughtException(Thread t, Throwable e) {
                System.out.println(t + " threw exception: " + e);
            }
        });
        thread.start();
    }
}

class MyThread implements Runnable {
    public void run() {
        throw new ArithmeticException();
    }

}