public boolean hasNext()
    {
        if(postingListMemoryMapped!=null && 
                entry >=0 && 
                entry < lexiconSize &&
                currentPos >=0 &&
                currentPos < toPos)
            return true;
        else{
            synchronized(this){
//                System.out.println("Releasing lock on posting list "+entry);
                inUse=false;
                this.notify(); //release exclusive access to the posting list
            }
            return false;
        }
         
    }