public Indir<Resource> getres(final int id) {
        synchronized (rescache) {
            Indir<Resource> ret = rescache.get(id);
            if (ret != null)
                return (ret);
            ret = new Indir<Resource>() {
                public int resid = id;
                Resource res;

                public Resource get() {
                    if (res == null)
                        return (null);
                    if (res.loading) {
                        res.boostprio(0);
                        return (null);
                    }
                    return (res);
                }

                public void set(Resource r) {
                    res = r;
                }

                public int compareTo(Indir<Resource> x) {
                    return ((this.getClass().cast(x)).resid - resid);
                }

                public String toString() {
                    if (res == null) {
                        return ("<res:" + resid + ">");
                    } else {
                        if (res.loading)
                            return ("<!" + res + ">");
                        else
                            return ("<" + res + ">");
                    }
                }
            };
            rescache.put(id, ret);
            return (ret);
        }
    }