[Xapian-discuss] Java threads

Olly Betts olly at survex.com
Thu Nov 1 21:11:05 GMT 2007


On Thu, Nov 01, 2007 at 01:53:28PM -0500, Aleph Thomas wrote:
> Well I have now a new question

If you have a new question, please start a new thread.  If you just
reply to a random unrelated message, it's harder to follow the
discussion and more likely your mail will be overlooked.  If you
make it easier for people to help you, you're more likely to get
help.

> well my app, is write in java, and I whant index all the files of my
> pc, I can use Xapian for multi threads, any example or suggesion about
> I need to do.

I'm not aware of any examples showing threaded use from Java.

The key thing to note is that a Xapian object can't be safely used from
multiple threads at once - you either need to use separate objects in
each thread, or protect the objects with a mutex.

For indexing, you can only have one WritableDatabase object for each
database, so you probably want to have a single thread handling updates,
and other threads passing Document objects to it to be added.

But assuming by "PC" you mean a typical desktop machine, I doubt it's
worth multithreading indexing of files - the main bottleneck is likely
to be reading data from the disks, and multithreading that probably
won't help performance.  Most PCs don't have a RAID for the disk
subsystem, so interleaving file accesses will probably just send the
disk head seeking back and forth.

Cheers,
    Olly



More information about the Xapian-discuss mailing list