lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Amin Mohammed-Coleman <ami...@gmail.com>
Subject Re: [EASY]How to change the demo of lucene143 into a multithread one?
Date Thu, 13 Aug 2009 11:25:33 GMT
Hi

I have recently created an indexing reference project using Spring
Integration.  May not help you with what you're doing but it might be
interesting for creating asynchronous indexing using JMS.

http://code.google.com/p/lucene-indexing-with-si/

Cheers
Amin


On Thu, Aug 13, 2009 at 11:53 AM, Chuan SHI <shichuanwuhan@gmail.com> wrote:

> Hi all,
>       I am new to multi-thread programming and lucene. I want to change the
> indexing demo of lucene143 into a multi-thread one. I create one instance
> of
> IndexWriter which is shared by three threads. But I find that the time it
> costs when three threads are used is approximate three times of that of
> single thread.(My computer is dual-core) It seems I write a pseudo
> multi-thread program and it does the same work for three times.
> Following is a snippet of my code. Please tell me how to write the correct
> code. Thanks.
>
> IndexWriter writer = new IndexWriter("D:\\index", new StandardAnalyzer(),
> true);
> File file=new File(args[0]);
> Thread t1=new Thread(new IndexFiles(writer,file));
> Thread t2=new Thread(new IndexFiles(writer,file));
> Thread t3=new Thread(new IndexFiles(writer,file));
> t1.start();
> t2.start();
> t3.start();
> writer.optimize();
> writer.close();
>
> while(t1.getState()!=State.TERMINATED
> ||t2.getState()!=State.TERMINATED
> ||t3.getState()!=State.TERMINATED
> ){}//wait until the threads end.
> Date end = new Date();
>
> --
> Best regards,
>
> Chuan SHI
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message