@Override
	public void run() {
		boolean done = false;
		int waitTime = 500;

		try {
			Packet pack = new Packet("GETCHUNK", "1.0", fileID, chunkNo, 0, null, null);
			DistributedBackupSystem.cManager.sendPacket(pack, CommunicationManager.Channels.MC);
			
			do {
				try {
					Thread.sleep(waitTime);
				} catch (InterruptedException e) {e.printStackTrace();}
				
				for(Packet p : messages) {
					if(p.getPacketType().equals("CHUNK") && Packet.bytesToHex(p.getFileID()).equals(Packet.bytesToHex(this.fileID)) && p.getChunkNo() == this.chunkNo) {
						BackupChunk chunk = p.getChunk();
						if(chunk.getSize() != 0)
							DistributedBackupSystem.fManager.writeChunk(chunk);
						/*if(chunk.getSize() < BackupChunk.maxSize )
							DistributedBackupSystem.tManager.sendMessageToActiveTasks(new Packet("FINISHRESTORE", "", chunk.getFileID(), -1, 0, null, null));*/
						done = true;
					}
				}

				if (waitTime < 10000)
					waitTime += waitTime;
				else
					done = true;
			} while (!done);
		} catch (IOException e) {e.printStackTrace();}
	}