ImageInputStream inputStream = ImageIO.createImageInputStream(p.getUrlThumbnail().openStream());
ImageInputStream inputStream = ImageIO.createImageInputStream(conn.getInputStream());
	public void run() {		Thread.yield();		int loaded = 0;		GalleryRemote._().getCore().getMainStatusUpdate().startProgress(StatusUpdate.LEVEL_CACHE, 0, toLoad.size(), GRI18n.getString(MODULE, "loadThmb"), false);		//Log.log(Log.TRACE, MODULE, "Starting " + iFilename);		while (!toLoad.isEmpty()) {			Picture p = (Picture) toLoad.pop();			Image i = null;			if (!thumbnails.containsKey(p)) {				if (p.isOnline()) {					Log.log(Log.LEVEL_TRACE, MODULE, "Fetching thumbnail " + p.getUrlThumbnail());					try {						ImageReader reader = (ImageReader) ImageIO.getImageReadersByFormatName("jpeg").next();						ImageInputStream inputStream = ImageIO.createImageInputStream(p.getUrlThumbnail().openStream());						reader.setInput(inputStream);						i = reader.read(0);						reader.dispose();					} catch (IIOException e) {						Log.logException(Log.LEVEL_ERROR, MODULE, e);					} catch (IOException e) {						Log.logException(Log.LEVEL_ERROR, MODULE, e);					}					if (i != null) {						Image scaled;						Dimension newD = ImageUtils.getSizeKeepRatio(								new Dimension(((BufferedImage) i).getWidth(), ((BufferedImage) i).getHeight()),								GalleryRemote._().properties.getThumbnailSize(), true);						if (newD != null) {							scaled = i.getScaledInstance(newD.width, newD.height, Image.SCALE_FAST);							i.flush();							i = scaled;						}					} else {						i = ImageUtils.unrecognizedThumbnail;					}				} else {					i = ImageUtils.load(							p.getSource().getPath(),							GalleryRemote._().properties.getThumbnailSize(),							ImageUtils.THUMB);				}				thumbnails.put(p, i);				loaded++;				Log.log(Log.LEVEL_TRACE, MODULE, "update progress " + loaded + "/" + (loaded + toLoad.size()));				GalleryRemote._().getCore().getMainStatusUpdate().updateProgressValue(StatusUpdate.LEVEL_CACHE, loaded, loaded + toLoad.size());				GalleryRemote._().getCore().thumbnailLoadedNotify();			}		}		stillRunning = false;		GalleryRemote._().getCore().getMainStatusUpdate().stopProgress(StatusUpdate.LEVEL_CACHE, GRI18n.getString(MODULE, "thmbLoaded"));		//Log.log(Log.TRACE, MODULE, "Ending");	}