Java JNI with QT application - Why it's use so many CPU resources?
-
I have Java JNI app with QT application.
Java class:
@
package my.site.processors.files.jni;import java.io.File;
/**
*-
@author ArtUrlWWW
*/
public class FfmpegStarter {public native void run(String pathToFfmpegExe, String paramsArr[]);
}
@QT code is:
@
#include "ffmpegstarterjni.h"
#include "mainwindow.h"
#include <QApplication>
#include <QStringList>FfmpegStarterJNI::FfmpegStarterJNI()
{
}JNIEXPORT void JNICALL Java_my_site_processors_files_jni_FfmpegStarter_run
(JNIEnv *env, jobject object, jstring pathToFfmpegExe, jobjectArray stringArray) {int argc=0; char *argv[1]; QApplication a(argc, argv); a.exec();
}
@
With this code Java JVM used 100% of one core (25% from 4-core CPU).If I comment a.exec(); code, then JVM doesn't use 100% of one CPU's core.
As I understand, this caused by a.exec(); (http://qt-project.org/doc/qt-5/qapplication.html#exec) - it makes loop, what can be ended by the QApplication::quit(); .
How to prevent huge CPU usage in JNI applications, which used QT and QApplication's function a.exec(); ?
-