Code example for WeakHashMap

Methods: get, put

0
 
    /** 
     * Get thread status and create one if specified. 
     */ 
    private synchronized ThreadStatus getOrCreateThreadStatus(Thread t) {
        ThreadStatus status = mThreadStatus.get(t);
        if (status == null) {
            status = new ThreadStatus();
            mThreadStatus.put(t, status);
        } 
        return status;
    } 
 
    public synchronized boolean canThreadDecoding(Thread t) {
        ThreadStatus status = mThreadStatus.get(t);
        if (status == null) {
            // allow decoding by default 
            return true; 
        } 
 
        boolean result = (status.mState != State.CANCEL);