pId = su.startProgress(0, pictures.size(), "Uploading pictures", false);
su.startProgress(StatusUpdate.LEVEL_UPLOAD_PROGRESS, 0, pictures.size(), "Uploading pictures", false);  if (su instanceof UploadProgress) { ((UploadProgress) su).setCancelListener(new ActionListener() { public void actionPerformed(ActionEvent e) { ((UploadProgress) su).updateProgressStatus(StatusUpdate.LEVEL_UPLOAD_PROGRESS, "Stopping upload..."); ((UploadProgress) su).setUndetermined(StatusUpdate.LEVEL_UPLOAD_PROGRESS, true); interrupt(); long startTime = System.currentTimeMillis();  while (!terminated && System.currentTimeMillis() < startTime + 10000) { try { Thread.sleep(1000); } catch (InterruptedException e1) {	} }  if (!terminated) { Log.log(Log.ERROR, "Thread would not terminate properly: killing it"); thread.stop();   cleanUp(); }  ((UploadProgress) su).setVisible(false); } }); }
		void runTask() {			ArrayList pictures = g.getAllPictures();						pId = su.startProgress(0, pictures.size(), "Uploading pictures", false);						// upload each file, one at a time			boolean allGood = true;			int uploadedCount = 0;			Iterator iter = pictures.iterator();			while (iter.hasNext() && allGood && !interrupt) {				Picture p = (Picture) iter.next();								su.updateProgressStatus(pId, "Uploading " + p.toString()					+ " (" + (uploadedCount + 1) + "/" + pictures.size() + ")");								allGood = uploadPicture(p);								su.updateProgressValue(pId, uploadedCount++);								if (allGood) {					p.getAlbum().removePicture(p);				}			}						if (allGood) {				su.stopProgress(pId, "Upload complete");			} else {				su.stopProgress(pId, "Upload failed");			}						pId = -1;		}