Categories
Uncategorized

Bank Program

import java.io.*; import java.util.Scanner; class LessBalanceException extends Exception { LessBalanceException(double amt) { System.out.println(“withdrawal of “+amt+”is invalid”); } } class Account { public String name; public double bal; Account(double bal,String n) { System.out.println(“\n New account opened \n”); this.bal=bal; name=n; System.out.println(“\n Thank you your new account with account name¬† “+name+” is created¬† with minimum balance of “+ […]

Categories
Uncategorized

Synchronization of Thread

Q) WAP to implements Thread Synchronization in Java. import java.util.Scanner; class Table{         void printTable(int n){       synchronized(this){//synchronized block       for(int i=1;i<=10;i++){             System.out.println(n+”*”+i+”=”+n*i);       try{               Thread.sleep(400);           }catch(Exception e){System.out.println(e);}        }      }           } }    public class sync{       public static void main(String args[])     {           final Table obj = new Table();//only one […]