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

每次都分配一个线程池,好像不太合理吧 #53

Open
mosentest opened this issue Nov 1, 2024 · 2 comments
Open

每次都分配一个线程池,好像不太合理吧 #53

mosentest opened this issue Nov 1, 2024 · 2 comments

Comments

@mosentest
Copy link

imageAnalysis.setAnalyzer(Executors.newSingleThreadExecutor(), image -> {
if (isAnalyze && !isAnalyzeResult && mAnalyzer != null) {
mAnalyzer.analyze(image, mOnAnalyzeListener);
}
image.close();
});

@jenly1314
Copy link
Owner

imageAnalysis.setAnalyzer(Executors.newSingleThreadExecutor(), image -> { if (isAnalyze && !isAnalyzeResult && mAnalyzer != null) { mAnalyzer.analyze(image, mOnAnalyzeListener); } image.close(); });

  • 没记错的话这段代码应该是 startCamera 方法中的一段; startCamera 方法一般也只在activity初始化之后调用一次,你怎么会认为是每次都分配一个线程池的?
  • 提问提错地方了,这段代码属于 CameraScan

@mosentest
Copy link
Author

mosentest commented Nov 1, 2024

imageAnalysis.setAnalyzer(Executors.newSingleThreadExecutor(), image -> { if (isAnalyze && !isAnalyzeResult && mAnalyzer != null) { mAnalyzer.analyze(image, mOnAnalyzeListener); } image.close(); });

  • 没记错的话这段代码应该是 startCamera 方法中的一段; startCamera 方法一般也只在activity初始化之后调用一次,你怎么会认为是每次都分配一个线程池的?
  • 提问提错地方了,这段代码属于 CameraScan

不好意思,我是从studio去跟踪代码,没留意。你多次打开这个页面不就会创建多个么?实际开发中这个页面不是首页吧

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

2 participants