1

JavaDoc for DBCursor says that results are lazy-fetching from the database. But

public class DBApiLayer extends DB {
    ...
    private void init( Response res ){
    ...
       _cur = res.iterator()
    ...
    }
    Iterator<DBObject> _cur;
    ...
}

contains all items that match the query (and they take heap as I understand it). And concurrent db.collection.update(...) doesn't change those objects. Is storing all objects in heap thread safe implementation?

Please explain me what does 'lazy' and 'thread safe' mean in this case.

4

1 回答 1

0

“懒惰”意味着下一批被懒惰地请求,因为客户端迭代 DBCursor。因此,如果您提前退出迭代,则不会获取其余结果。

您提到的页面中的“线程安全”并不意味着驱动程序中的每个类都可以安全地同时使用我的多个线程。在实践中,MongoClient、DB 和 DBCollection 是线程安全的,而 DBCursor 和 DBObject 则不是。

于 2013-05-26T15:55:21.103 回答