Threading

15 views
Skip to first unread message

defonion

unread,
Apr 8, 2013, 5:00:32 PM4/8/13
to tt4j-...@googlegroups.com
Hi,

is there a recommended way to use tt4j with different threads, e.g. charing an instance between the threads or creating a new instance for every thread?

best regards

Richard Eckart de Castilho

unread,
Apr 8, 2013, 5:06:38 PM4/8/13
to tt4j-...@googlegroups.com
Hi,

TT4J is not thread-safe. Each TT4J instance talks to one TreeTagger process. If you'd access it from multiple threads, the best thing that could happen is that you'd feed the TreeTagger process with a mix of input from each thread, but its more probably that the whole thing would just crash and burn.

You should create one instance per thread. If you create throw-away threads (a lot of them), you may want your TT4J instance to live longer than an individual thread. In that case, you should try some pooling approach.

Cheers,

-- Richard

defonion

unread,
Apr 9, 2013, 3:44:55 PM4/9/13
to tt4j-...@googlegroups.com
Thanks for your fast reply. I think i'll give the pooling approach a try.
Reply all
Reply to author
Forward
0 new messages