Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Using lazy initialization for the database in a web crawler is probably not worthwhile. Lazy initialization adds complexity and an ongoing speed hit. One case where it is justified is when there is a good chance the data will never be needed. Also, in an interactive application, it can be used to reduce startup time and give the <em>illusion</em> of speed.</p> <p>For a non-interactive application like a web-crawler, which will surely need its database to exist right away, lazy initialization is a poor fit.</p> <p>On the other hand, a web-crawler is easily parallelizable, and will benefit greatly from being multi-threaded. Using it as an exercise to master the <code>java.util.concurrent</code> library would be extremely worthwhile. Specifically, look at <a href="http://java.sun.com/javase/6/docs/api/java/util/concurrent/ConcurrentHashMap.html" rel="noreferrer"><code>ConcurrentHashMap</code></a> and <a href="http://java.sun.com/javase/6/docs/api/java/util/concurrent/ConcurrentSkipListMap.html" rel="noreferrer"><code>ConcurrentSkipListMap</code>,</a> which will allow multiple threads to read and update a shared map.</p> <p>When you get rid of lazy initialization, the simplest Singleton pattern is something like this:</p> <pre><code>class Singleton { static final Singleton INSTANCE = new Singleton(); private Singleton() { } ... } </code></pre> <p>The keyword <code>final</code> is the key here. Even if you provide a <code>static</code> "getter" for the singleton rather than allowing direct field access, making the singleton <code>final</code> helps to ensure correctness and allows more aggressive optimization by the JIT compiler.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload