Hi,
you can try the folowing:
When the user close the window you can send an event msg to your thread
that will perform special code that you will write for this case and
than he will quit from the run method (will shutdown/stop) and then the
garbage collector will do the final work...
> i know its already implemented but when user close the window
> intentionally then what we wish is to unload the whole game
> immediately, although we set the appose the conditions it still regised
> in the memory and that is the problem.
Memory deallocation isn't your problem -- Java is a garbage-collected
language, so once the references go away the memory is freed (not
instantly, but your responsibility ends). It's possible to have memory
leaks by keeping references around accidentally in various ways, but
that's another matter. Your problem is, if I understand you correctly,
that you've spun off multiple threads and they're not all stopping when
your main thread stops due to the window closing.
The scheme I recommended is a fairly universal idiom for managing
thread lifespan. Without seeing any code to the contrary, I must
assume that there is a flaw in your implementation, because the idiom
is sound. Perhaps when you set and/or check the variable upon which
the condition hinges, you are not performing appropriate
synchronization.
Luke
P.S. Every time I get on the topic of Java synchronization, I have to
plug Doug Lea's book "Concurrent Programming in Java." It's rad, read
it.
vidhi - 03 Jan 2006 11:07 GMT
u get the problem, actualy the main thread is stoped due to user action
of closing window if i stoped thread with altering condition threads
might be stoped but they still occupied memory, for example if any
sound file is playing then it continusly stated play this give a big
hint that why memory used is not freed as all the images and other
files are still in the memory.
i already used to null all the main objects and run Runtime.gc() &
System.gc() methods for garbegh collection.
still same.
Thomas Schodt - 03 Jan 2006 14:11 GMT
> u get the problem, actualy the main thread is stoped due to user action
> of closing window if i stoped thread with altering condition threads
[quoted text clipped - 5 lines]
> i already used to null all the main objects and run Runtime.gc() &
> System.gc() methods for garbegh collection.
<http://forum.java.sun.com/thread.jspa?threadID=695880>
Roedy Green - 03 Jan 2006 22:40 GMT
>It's possible to have memory
>leaks by keeping references around accidentally in various ways, but
>that's another matter.
see http://mindprod.com/jgloss/packratting.html
for various places you may accidentally hold onto references you don't
really need.

Signature
Canadian Mind Products, Roedy Green.
http://mindprod.com Java custom programming, consulting and coaching.