(Why) Is Java not available in a thread-based environment?
조회 수: 5 (최근 30일)
이전 댓글 표시
From my experience, using Java features (e.g. java.util.LinkedList) is smooth within MATLAB. However, these features are unavailable when called from a thread-based environment. A simplified example would be:
msgbase=javachk('jvm');
ph=parpool('Threads',2);
f=parfeval(ph,@jthreads,1);
[~,msgth]=f.fetchNext();
delete(ph);
function MSG=jthreads()
MSG=javachk('jvm');
end
Where msgbase would be empty, indicating Java is usable, but msgth would be 'This feature is not supported because:Java is not currently available.' I was not able to find a official statement on this issue, or a previous insightful discussion.
- Is this expected behavior?
- Can I modified settings or append some parameters to enable Java features inside a thread-based environment?
- I'm not familar with C MEX funtions but I could learn. However, is C MEX functions supported inside a thread-based environment?
Thanks and regards!
댓글 수: 0
답변 (1개)
Damian Pietrus
2024년 3월 19일
Currently, thread pools do not support all functions and features that process pools do. Stealing from our doc page here:
In general, functionality in Graphics, App Building, External Language Interfaces, Files and Folders, and Environment and Settings is not supported.
댓글 수: 1
Jan Kappen
2024년 5월 22일
Interestingly, Python seems to be supported to some extend, see pass Python object as argument to function in "parfeval" - MATLAB Answers - MATLAB Central (mathworks.com)
Does this work with C/C++ and Java interfaces, too? Where exactly are the limitations?
참고 항목
카테고리
Help Center 및 File Exchange에서 Startup and Shutdown에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!