I'm working on a simple application and now I'm not quite sure how to deal with errors occured while executing application. I'm particularly worried about OutOfMemoryError. Example:
    try{
        while(true){
            //do some job
        }
    } catch (Exception e){
        System.out.println("Exception occured");
    } catch (Throwable t){
        //log entry of abnormal termination
        System.exit(1);
    } finally {
        //Terminate application normally
    }
Is it a correct way to deal with such situation? I mean to attempt to terminate application normally in finally block and just kill JVM in catch(Throwable t).
The issue is finally will never be executed if, say, OutOfMemoryError was thrown.