@Override
    public void run(){   
    	try {
			sequencer.open();
		} catch (MidiUnavailableException e1) {
			// TODO Auto-generated catch block
			e1.printStackTrace();
		}
        sequencer.start();
        while(true) {
            if(sequencer.isRunning()) {
            	run=true;
            	sequencer.start();
            	try {
    				Thread.sleep(100000);
    			} catch (InterruptedException e) {
    				e.printStackTrace();
    			}
            }
            else{ 
            	run=true;
            	
            	sequencer.close();
                break;
            }            
       }
    }