lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Ilya Khandamirov" <...@startext.de>
Subject RE: IndexReader Pool
Date Mon, 08 Jul 2002 15:59:30 GMT
Hi Scott,

I get deadlocks with the following test code:

File indDir = new File( "C:\\index" );
for ( int i = 0; i < 49; i++ )
{
  IndexReader reader = IndexAccessControl.getReader( indDir );
  Thread t = new Thread()
  {
    public void run()
    {
      File indDir = new File( "C:\\index" );
      try
      {
        IndexWriter writer = IndexAccessControl.getWriter( indDir );
        IndexAccessControl.releaseWriter( indDir, writer );
      }
      catch ( IOException e )
      {
        e.printStackTrace();
      }
    }
  };
  t.start();
  System.out.println( i );
  IndexAccessControl.releaseReader( indDir, reader );
}


To avoid that i decided to synchronize (and wait/notify) only on sync.
Since that it looks like it works correctly. What do you think?


Regards,
Ilya



-----Original Message-----
From: Scott Ganyo [mailto:scott.ganyo@eTapestry.com] 
Sent: Montag, 8. Juli 2002 16:28
To: 'Lucene Users List'
Subject: RE: IndexReader Pool


Deadlocks could be created if the order in which locks are obtained is
not consistent.  Note, though, that the locks are obtained in the same
order each time throughout.  (BTW: The inner lock is merely needed
because the wait/notify calls need to own the monitor.)

Naturally, you are free to make any suggestions for improvement! :)

Scott


--
To unsubscribe, e-mail:   <mailto:lucene-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:lucene-user-help@jakarta.apache.org>


Mime
View raw message