I want to monitor the memory usage and threading, how can I do on the Eclipse or JVM? Thanks.
in Eclipse, run the program in debug mode (this will also open the debug perspective). In that you can see how many threads are running. The best tool for this could be an inbuilt profiler . I guess JVM has a profiling tool as well or you can use third party profiling tool like JProfiler or yourkit. http://www.yourkit.com/
JProfiler provides a lot of useful information on threading and monitor contention and it has an eclipse plugin.
See these screen casts for monitor contention analysis:
Disclaimer: My company develops JProfiler
You can try jvisualvm.exe
You can find it in jdk/bin directory. It's great tool.
Read here on the usage of it.
If you want to get the status in your java code, you can try JMX. Google the keywords "JMX Monitoring and Management".