简体   繁体   中英

Multiple Threads in a JVM

I have 1 GB of memory allocated to a JVM . I want to generate multiple threads executing some functionality.How can I know how much of JVM space is taken up by the single thread.

This depends on your JVM. For HotSpot , there's a java application launcher VM option to set the size of the thread stack:

XX:ThreadStackSize=512

If you are using Oracle's JVM:

Thread t = new Thread(); //to simulate your thread

com.sun.managment.ThreadMXBean tmxb =   ManagmentFactory.getThreadMXBean();

long mem = tmxb.getThreadAllocatedBytes(t.getId());

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM