Skip to content

CBTaggingDecoder实例化对象多线程安全问题 #14

Description

@chenying99

您好,CBTaggingDecoder实例化对象多线程调用存在线程安全问题,里面的成员变量不是线程安全的

每次调用分词方法存在对成员变量的写操作;

反之,如果每次new一个CBTaggingDecoder对象(初始化成员变量等),则模型文件需要重新加载,开销很大

能不能优化一下,使得既能够多线程调用,然后不需要重新加载模型文件(至少重用模型数据结构,或者CBTaggingDecoder对象单例化)

这里的部分成员变量在调用分词方法 有写操作
private int maxLength;
private int len;
private String sequence;
private int[][] allowedLabelLists;
private int[][] pocsToTags;

private CBNGramFeature nGramFeature;
private Dat dat;

private CBModel model;

private Node[] nodes;
private int[] values;
private AlphaBeta[] alphas;
private int[] result;

private String[] labelInfo;

private int[][] labelTransPre;
private int[][] labelTransPost;

public int threshold;

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions