JNI C++ importatn process

M

Marcelo

Hi,

I have a problem with my JNI application. Actually the C++ application
that is called from my java program is very very important. Because the
calculations last a lot of the time, I would like to know how to manage
them like as background thread.

I am using a link between GUI and C++, but with this calculation
problem, the GUI gets blocked.

what can I do?

Marcelo
 
M

Marcelo

because it is inside a GUI
should I use a SwingUtilities ?


javax.swing.SwingUtilities.invokeLater(new Runnable() {
public void run() {
greatC++();
}
});

thanks

Marcelo
 
T

Thomas Fritsch

Marcelo said:
because it is inside a GUI
should I use a SwingUtilities ?


javax.swing.SwingUtilities.invokeLater(new Runnable() {
public void run() {
greatC++();
}
});
NOOOO! With SwingUtilities.invokeLater you tell Java to call greatC++()
from the GUI(!) thread. Hence the GUI will be blocked as long as it runs
greatC++().
Instead you want greatC++() to be called by ANOTHER thread. Create a new
Thread and then start it by yourself.
I recommend reading a good text-book (or the Java tutorial) about the
Thread and Runnable stuff.
 
R

Roedy Green

javax.swing.SwingUtilities.invokeLater(new Runnable() {
public void run() {
greatC++();
}
});

Definitely not. Everything will come to grinding halt when that great
c task hogs the Swing event thread. You need a NEW background thread
to run your big task on.

See http://mindprod.com/jgloss/thread.html

In particular look at the SwingWorker class.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,780
Messages
2,569,609
Members
45,254
Latest member
Top Crypto TwitterChannel

Latest Threads

Top