public void run() {
    	try{
    		// Keep trying to connect
    		while(true){
    			_cn.connect();
    			if(_cn.getSocket().isConnected())
    			{
    				_sw = new SyncStreamWriter(_fm.getHome(),new DataOutputStream(_cn.getSocket().getOutputStream()),_debug);
    				_sp = new SyncStreamParser(_fm.getHome(),new DataInputStream(_cn.getSocket().getInputStream()),_debug);
    				// The first time we connect we write a query package to get the files from server 
    				System.out.println("Sent a package to server to query");
    				_sw.writePackageHeader(ProtocolConstants.PACK_QUERY_HEAD);
    				Thread.sleep(DropboxConstants.SYNC_SLEEP_MILLIS);
    				break;
    			}
    		}
    			// We get a connection, then sync
    		while(_cn != null && _cn.getSocket().isConnected()&& !_cn.getSocket().isClosed()){
    			
    			// Check the stream;
    			sync();
    			
    			Thread.sleep(DropboxConstants.SYNC_SLEEP_MILLIS);
    		}
    		
    	}catch(InterruptedException e){
    		System.err.println("Thread sleep error");
    		if( _debug )
    			e.printStackTrace();
    	}catch(IOException e){
    		System.err.println("Write stream error");
    		if( _debug )
    			e.printStackTrace();
    	}
    	finally{
    		_cn.close();
    	}
    	
    	System.out.println("Finish sync");
    }