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

多个线程同时调用 AviatorEvaluator.execute() 会存在多线程安全问题吗 #91

Closed
haoyuanqiang opened this issue Dec 5, 2018 · 4 comments

Comments

@haoyuanqiang
Copy link

现在有一个需求,需要多线程并发执行计算任务,每个任务都会调用 AviatorEvaluator.execute() 进行表达式计算,如果不做任何措施,会存在线程安全问题吗?

@killme2008
Copy link
Owner

AviatorEvaluator.execute() 本身是线程安全的。只要你的表达式执行逻辑是线程安全的,传入的 env 是线程安全的,那就没有问题。

@haoyuanqiang
Copy link
Author

好的,谢谢,这样我就可以放心的在项目中使用了

@Noodles-Buddy
Copy link

请问大神,env为确保线程安全的话,是否需要传入ConcurrentHashMap?

@killme2008
Copy link
Owner

核心的问题是你的 env 是否会被并发修改,跟传不传没关系。如果没有,那就不用 ConcurrentHashMap

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