Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

是否可以多线程调用? #56

Open
marletto opened this issue Sep 19, 2018 · 4 comments
Open

是否可以多线程调用? #56

marletto opened this issue Sep 19, 2018 · 4 comments

Comments

@marletto
Copy link

目前用单线程, 第一次调用 segmenter.Cut 的时候发现比较慢, 估计是懒初始化.
那么在第一次调用以后, 后面是不是就可以多线程调用了呢?
如果对词库等全局变量仅仅是只读, 那么理论上是可以支持多线程的

@anderscui
Copy link
Owner

@marletto 理论上是可以的,但之前没有测试过。

@Nieg
Copy link
Contributor

Nieg commented Mar 1, 2019

@marletto 理论上是可以的,但之前没有测试过。

我使用的时候出现了个bug,也知道问题原因。 晚点给你单独提个issue,并和你讨论一下。

@anderscui
Copy link
Owner

@Nieg 当时的 bug 还记得是什么吗?

@Nieg
Copy link
Contributor

Nieg commented Apr 3, 2020

使用发生状况有几个条件。。。
1.使用自定义词典,而且词典的量要足够大。
2.首次访问在极短时间内连续访问多次。
具体原因是:自定义词典初始化的时候,并未加锁。导致自定义词库Dictionary 多线程 Add 后,内部哈希表 链表结构死循环了。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants