diff --git a/src/com/silverwrist/util/ParallelRunQueue.java b/src/com/silverwrist/util/ParallelRunQueue.java
deleted file mode 100644
index 0e29672..0000000
--- a/src/com/silverwrist/util/ParallelRunQueue.java
+++ /dev/null
@@ -1,154 +0,0 @@
-/*
- * The contents of this file are subject to the Mozilla Public License Version 1.1
- * (the "License"); you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at .
- *
- * Software distributed under the License is distributed on an "AS IS" basis, WITHOUT
- * WARRANTY OF ANY KIND, either express or implied. See the License for the specific
- * language governing rights and limitations under the License.
- *
- * The Original Code is the Venice Web Communities System.
- *
- * The Initial Developer of the Original Code is Eric J. Bowersox ,
- * for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
- * Copyright (C) 2001 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
- *
- * Contributor(s):
- */
-package com.silverwrist.util;
-
-import java.util.Vector;
-
-/**
- * A class which takes any number of Runnable
objects, and executes them in parallel on
- * multiple threads insofar as possible.
- *
- * @author Eric J. Bowersox <erbo@silcom.com>
- * @version X
- * @see java.lang.Runnable
- * @see java.lang.Thread
- */
-public class ParallelRunQueue implements Runnable
-{
- /*--------------------------------------------------------------------------------
- * Attributes
- *--------------------------------------------------------------------------------
- */
-
- private Thread[] thrds; // the current threads
- private Vector queue; // the queue of Runnables to be run
- private int priority; // the priority to use for all these threads
-
- /*--------------------------------------------------------------------------------
- * Constructor
- *--------------------------------------------------------------------------------
- */
-
- /**
- * Creates a new ParallelRunQueue
.
- *
- * @param nthread Number of threads to be executed in parallel with the current one by this run queue.
- */
- public ParallelRunQueue(int nthread)
- {
- thrds = new Thread[nthread];
- for (int i=0; iRunnable objects currently queued. When this method returns, the run queue
- * is empty. The objects are executed on one of the internal worker threads, or on the current thread
- * if no other threads are available.
- */
- public void run()
- {
- while (queue.size()>0)
- { // unqueue a new Runnable
- Runnable r = (Runnable)(queue.remove(0));
- for (int i=0; iRunnable object onto the queue. If a worker thread is available, the
- * new object is started running immediately.
- *
- * @param r The Runnable
object to enqueue.
- */
- public void queue(Runnable r)
- {
- for (int i=0; iRunnable objects remain, then dead threads are nulled out to
- * garbage-collect them.
- */
- public void work()
- {
- for (int i=0; i section.
sect = loader.configGetSubSection(config_h,"dictionary");
// Retrieve the list of dictionary files.
Collection dictionary_tmp = getDictionaryNames(sect,application_root);
+ // Load the lexicon with all the dictionary files.
+ LazyTreeLexicon lex = new LazyTreeLexicon((String[])(dictionary_tmp.toArray(new String[0])));
+ this.queueTask(lex,TASK_PRIO_MAX-2); // load the lexicon
+
// Create the intermediate object map for HTML checker creation, and "seed" it.
HashMap intermediate_map = new HashMap();
SpellingRewriter spell_rewriter = new SpellingRewriter();
- LazyTreeLexicon lex = new LazyTreeLexicon((String[])(dictionary_tmp.toArray(new String[0])));
spell_rewriter.addDictionary(lex);
intermediate_map.put(spell_rewriter.getClass().getName(),spell_rewriter);
PostLinkRewriter postlink_rewriter = new PostLinkRewriter(this);
@@ -171,7 +212,6 @@ public class GlobalSiteImpl implements GlobalSite
// Get the section.
sect = loader.configGetSubSection(config_h,"html-checker");
NodeList nl = sect.getChildNodes();
- int i;
for (i=0; i,
* for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
- * Copyright (C) 2001 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
+ * Copyright (C) 2001-02 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
*
* Contributor(s):
*/
@@ -28,14 +28,14 @@ public class LazyLexicon implements Runnable, SpellingDictionary
*--------------------------------------------------------------------------------
*/
- private static Category logger = Category.getInstance(LazyLexicon.class.getName());
+ private static Category logger = Category.getInstance(LazyLexicon.class);
/*--------------------------------------------------------------------------------
* Attributes
*--------------------------------------------------------------------------------
*/
- private Lexicon inner_lex = null;
+ private volatile Lexicon inner_lex = null;
private String[] filenames;
/*--------------------------------------------------------------------------------
@@ -47,9 +47,7 @@ public class LazyLexicon implements Runnable, SpellingDictionary
{
this.filenames = filenames; // save off the file names to be loaded
- // spin off the load process into the background
- Thread thrd = new Thread(this);
- thrd.start();
+ // do not background the load yet, we'll queue it as a task
} // end constructor
@@ -90,7 +88,7 @@ public class LazyLexicon implements Runnable, SpellingDictionary
Lexicon lex = new Lexicon();
if (logger.isDebugEnabled())
- logger.debug("LazyLexicon loading " + String.valueOf(filenames.length) + " lexicon(s)");
+ logger.debug("LazyLexicon loading " + filenames.length + " lexicon(s)");
for (int i=0; i,
* for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
- * Copyright (C) 2001 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
+ * Copyright (C) 2001-02 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
*
* Contributor(s):
*/
@@ -28,14 +28,14 @@ public class LazyTreeLexicon implements Runnable, SpellingDictionary
*--------------------------------------------------------------------------------
*/
- private static Category logger = Category.getInstance(LazyTreeLexicon.class.getName());
+ private static Category logger = Category.getInstance(LazyTreeLexicon.class);
/*--------------------------------------------------------------------------------
* Attributes
*--------------------------------------------------------------------------------
*/
- TreeLexicon inner_lex = null;
+ volatile TreeLexicon inner_lex = null;
private String[] filenames;
/*--------------------------------------------------------------------------------
@@ -47,9 +47,7 @@ public class LazyTreeLexicon implements Runnable, SpellingDictionary
{
this.filenames = filenames; // save off the file names to be loaded
- // spin off the load process into the background
- Thread thrd = new Thread(this);
- thrd.start();
+ // do not start a new thread, we'll queue the lexicon up as a task
} // end constructor
@@ -63,7 +61,7 @@ public class LazyTreeLexicon implements Runnable, SpellingDictionary
while (inner_lex==null)
{ // wait for the inner thread to finish creating the lexicon
if (logger.isDebugEnabled())
- logger.debug("LazyLexicon: waiting for lex to load...");
+ logger.debug("LazyTreeLexicon: waiting for lex to load...");
try
{ // park the thread here until we know what's up
@@ -90,7 +88,7 @@ public class LazyTreeLexicon implements Runnable, SpellingDictionary
TreeLexicon lex = new TreeLexicon();
if (logger.isDebugEnabled())
- logger.debug("LazyTreeLexicon loading " + String.valueOf(filenames.length) + " lexicon(s)");
+ logger.debug("LazyTreeLexicon loading " + filenames.length + " lexicon(s)");
for (int i=0; i