public void run() {
		
		try {
			URL url = new URL(URL);
			HttpURLConnection httpConnection = (HttpURLConnection) url
					.openConnection();
			String sProperty = "bytes=" + startPos + "-";
			//using net.httpURLConnection to set property
			httpConnection.setRequestProperty("RANGE", sProperty);
			// System.out.println("Thread no."+threadID+" is now downloading...");
			textArea.append("\nThread" + threadID + " is now downloading");
			InputStream input = httpConnection.getInputStream();
			byte[] buf = new byte[1024];
			//read 1024b everytime
			int offset;
			offset = (int) endPos - (int) startPos;
			if (offset > 1024)
				offset = 1024;
			while ((inc = input.read(buf, 0, offset)) > 0 && startPos < endPos) {
				//last part of file < 1024
				if (((int) endPos - (int) startPos) < 1024)
					inc = (int) endPos - (int) startPos;
				/*
				 * if(inc<1024){
				 * System.out.println("inc is :"+inc+" -- startpos is "+startPos);
				 * }
				 */
				readPos += inc;
				// System.out.println("read "+inc+" bytes");
				textArea.append("\nThread" + threadID + " reads " + readPos
						+ "bytes, start is :" + startPos + " and end is:"
						+ endPos);
				offset = (int) endPos - (int) startPos;
				if (offset > 1024)
					offset = 1024;
				// System.out.println("threadID: "+threadID+" started: "+startPos+" offset: "+offset);
				//write to file
				file.write(buf, 0, inc);
				startPos += inc;

			}
			// System.out.println("thread "+threadID+" complete");

			textArea.append("\nThread" + threadID + " complete");
			file.close();
			input.close();
		} catch (Exception ex) {

		}
	}