Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo

Close

JWNL problem : deadlock in multithread enviro

Help
2007-01-11
2013-04-29
  • Hi All,

    I'm using JWNL 1.3 at http://www.online-utility.org/english/index.jsp English language online tools.

    But sometimes some of my widgets which use JWNL stop to work. It seems like some kind of deadlock.
    I'm using File mapped dictionary.

    Usually each JSP (Servlet) use class WordNetProcessor which use JWNL in static way as follows:
    <%! static WordNetProcessor wordNetProcessor=new WordNetProcessor(); %>

    Class WordNetProcessor initialize JWNL at the following way :
        /** Creates a new instance of WordNetProcessor */
        public WordNetProcessor() {
            String propsFile = common.CommonResource.getString("WordNetProperty");
            try {
                // initialize JWNL (this must be done before JWNL can be used)
                if(!JWNL.isInitialized())
                    JWNL.initialize(new FileInputStream(propsFile));
                dic=Dictionary.getInstance();
            } catch (Exception ex) {
                ex.printStackTrace();
            }
        }

    I've tried also with the line if(!JWNL.isInitialized()) removed but it seemed I had leak of file descriptors.

    I would appreciate any idea or comment.

    Thanks in advance.

     
  • You might have faced some of the multithreading issues people in other forums talk about. In my fork at http://extjwnl.sourceforge.net/ there is a way to use Dictionary normally, not only with a single static instance. You may want to try to instantiate dictionary per thread.