i’ve got the following problem:i’ve built an applet which starts a thread. this thread periodically looks for new entries in a view, releases the notes objects again, and then the sleep(time) function is called.
now my problem is, that when i try to close the form, that contains the applet, while this thread looks for new data, notes crashes.
i’m using Version 6.01, and the applet is running within the notes system.
Subject: are notes java objects thread save?
Hm…
I think you are using NotesThread.sinitThread() and NotesThread.stermThread() in your data fetch thread? If this is correct i suggest to end this thread correctly with NotesThread.stermThread() in the applet.stop() method.
I hope this helps
Maybe you can post simple example applet with the code.
Subject: RE: are notes java objects thread save?
One thing that you should have in main is that every time you open a Session
Session s = NotesFactory.createSession(serverName);
after you do all your work with the session you should remember to do a:
s.recycle();
otherwise you will leave all the C/C++ objets of the Notes side open and you will run out of handlers in the server side… (it is easy to arrive to this situation in concurrency environments…)
Best,
Sergio
Subject: RE: are notes java objects thread save?
thanks for your response!
the simplified thread code goes like this:
public class T extends Thread {
public boolean stopped = false;
public int Interval;
public void run() {
while(!stopped) {
try {sleep(Interval);}
catch (InterruptedException e){}
if (!stopped) startUpdate();
}
}
public synchronized void startUpdate() {
lotus.domino.NotesThread.sinitThread();
....
lotus.domino.NotesThread.stermThread();
}
}
and the simplified code of the applet destroy method was like this:
public void notesAppletDestroy() {
t.stopped = true;
try {t.join();}
catch (Exception e) {}
}
but now i’ve constructed a workaround for this problem, the user has to use an exit button that stops the thread, and afterwards the user may close the applet. since i don’t know any better solution this is much better than a notes crash