• Post Reply Bookmark Topic Watch Topic
  • New Topic

getAllStackTraces() & activeCount()  RSS feed

 
Mandar Khire
Ranch Hand
Posts: 588
Android Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I write very simple program

When 1st println runs i got


{
Thread[Attach Listener,5,system]=[Ljava.lang.StackTraceElement;@66848c,
Thread[Signal Dispatcher,9,system]=[Ljava.lang.StackTraceElement;@8813f2,
Thread[Reference Handler,10,system]=[Ljava.lang.StackTraceElement;@1d58aae,
Thread[Finalizer,8,system]=[Ljava.lang.StackTraceElement;@83cc67,
Thread[AWT-Shutdown,5,main]=[Ljava.lang.StackTraceElement;@e09713,
Thread[Java2D Disposer,10,system]=[Ljava.lang.StackTraceElement;@de6f34,
Thread[AWT-Windows,6,main]=[Ljava.lang.StackTraceElement;@156ee8e,
Thread[AWT-EventQueue-0,6,main]=[Ljava.lang.StackTraceElement;@47b480,
Thread[DestroyJavaVM,5,main]=[Ljava.lang.StackTraceElement;@19b49e6
}

when 2nd println runs i got

4

my question is when i debug program i got

HelloExample [Java Application]
HelloExample at localhost:1611
Thread [AWT-Shutdown] (Running)
Daemon Thread [AWT-Windows] (Running)
Thread [DestroyJavaVM] (Running)
Thread [AWT-EventQueue-0] (Suspended (breakpoint at line 29 in HelloExample$1))
C:\Program Files\Java\jre6\bin\javaw.exe (Jun 1, 2012 5:28:22 PM)


I think that 4 which i got by java.lang.Thread.activeCount() is
1 Thread [AWT-Shutdown] (Running)
2 Daemon Thread [AWT-Windows] (Running)
3 Thread [DestroyJavaVM] (Running)
4 Thread [AWT-EventQueue-0]

but then what are those 9 threads? how can i get detailed info regarding all this? i try google but not get better way!
I read activecount & getStackTrace, but it just introduction of it.
 
Jaikiran Pai
Sheriff
Posts: 10447
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't know why you are trying to correlate the output of those two methods, but anyway, the javadoc on the activeCount() method has an important piece of information:

Returns the number of active threads in the current thread's thread group.
 
Mandar Khire
Ranch Hand
Posts: 588
Android Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am trying to understand all about how any program execute in jvm!
Is it helpful to learn how various program execute in jvm? Many programmer just know by writing particular line in java what it does like println we can print line in console in new line. But not know how actually java works...in fast life we think machine do its work properly so no bother, why learn just print what ever you want & forget about what done in background.
But i am not thinking that way so i try to debug small program & see what happen.
Now i download eclipse indigo & in it few plug-in like bytecode outline,bytecode visualizer, sourcecode visualizer etc
By that i got info about bytecode of my program.
I read about ASM.
What is best way to learn about bytecode? Or for that i should learn about this ASM first?
When i use clean & build in eclipse .class file generated..so i read Difference-between-class-jar-java & article.
Many more links i got when i search keywords related jvm,class file,bytecode, java file debugging etc
Is there any book/blog where all collective study present. so i can get all answers of my questions 'why' 'what' 'when' 'where' 'whom' 'how'?
Right now i am reading jvms7.pdf, & try to getting more info from jcp.org.
But all this is intermediate level, in need step by step.
Thanks
 
Jaikiran Pai
Sheriff
Posts: 10447
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am glad that you want to learn these things, but your new post has nothing to do with the original question in this thread. Furthermore, you are asking way too many different things in a single post which makes it difficult to point you in the right direction. Take one step at a time. For example, keep out the IDE from the equation for now. Also, in my opinion, you are jumping to a higher level without first getting to the basics. Bytecode, ASM, JVM implementation aren't simple. You have to first understand the basics of Java programming before jumping into those details. So I would recommend you first start learning Java programming (which involves working with available APIs) and understanding the code, before diving into the internals of JVM.
 
Mandar Khire
Ranch Hand
Posts: 588
Android Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for instant reply...
So I would recommend you first start learning Java programming (which involves working with available APIs) and understanding the code, before diving into the internals of JVM.

How i prove that 'now i think i learned basic java programming with IDE or without IDE'.
Actually i write program, i ask lots of question regarding it in various sections of this forum & got lots of useful answers
Swing
1.
2.
3.

JDBC
1.
2.

ORM
1.
2.

Now after many days i got free time for learning few new things...so i ask...my problem is i always can not keep specific question at one time because when i search answer & i got 1 more new thing, when i search that one then again 1 more thing come forward & chain going on & on. So trouble to ask what & where i got problem.
same time i use search in coderanch.
 
Mandar Khire
Ranch Hand
Posts: 588
Android Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
After reading so much of other things which looks like
but your new post has nothing to do with the original question in this thread.

I write simple hello world program


& debug it. I got

When i add 2 lines in code,below System.out.println("Hello World");

I got result in console

My question is for understand Reference Handler,Finalizer,Signal Dispatcher,Attach Listener should i learn first details of bytecode etc which i write in above 2-3 replays?
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!