Do you still remember about the stack trace and the fact that the currently running method is at the top of the stack? Let's recall this by completing a task: you need to create a "task" (a public static class called SpecialThread that implements the Runnable interface). SpecialThread should display its own stack trace.
Displaying a stack trace
You must be signed in to leave a comment
3 September 2022, 20:04
I'm not sure I understand how to read the result of this exercise. Is the purpose just to show that each thread has its own stack trace? If so, what is the purpose of the for loop?
23 January, 09:10
The purpose of the for-each loop is to print every element of the array produced by getStackTrace() method.