1

I register a JVMTI Event MethodEntry and its callback function is tdMethodEntry and if there are many many MethodEntry Events and my question is that

these event will be processed by the same thread through queue? or be processed by several threads?

nail fei
  • 2,179
  • 3
  • 16
  • 36

1 Answers1

1

MethodEntry callbacks, like many other JVMTI event callbacks, are executed synchronously on the application thread that caused this event. If the application runs multiple threads, MethodEntry callbacks may run concurrently on these threads. Events are not queued.

See JVMTI spec Events section.

apangin
  • 92,924
  • 10
  • 193
  • 247
  • if there are ***only one application thread*** but the callback does many things (consuming largely time). On this occasion, while ***only one thread***, there should be ***multiple threads*** run callback to executed synchronously on the application thread ? – nail fei Nov 10 '16 at 01:51
  • @cainiaofei No, callbacks run on the same thread as the application code. From the application perspective the thread is stopped while a callback is in progress. – apangin Nov 10 '16 at 21:01
  • that is to say all **MethodEntry Event** processed by the same *one* thread? I am a little confuse, for through my program output I think it is processed by more than one thread. – nail fei Nov 11 '16 at 02:46
  • @cainiaofei Yes, by the same one thread. What's wrong with the output? – apangin Nov 11 '16 at 07:21
  • In order to better describe my question, I place the code and the output description on github, [code and issue](https://github.com/cainiaofei/issueCommunicate]) the code is the file called **methodEntryCapturer** and output description called **issueDescription** . – nail fei Nov 11 '16 at 08:42
  • @cainiaofei Yes, the output indicates you have multiple Java threads running. The assumption that there is only one application thread seems to be incorrect. BTW, MethodEntry callback receives `jthread` as one of parameters - you can check what thread exactly calls this event. – apangin Nov 16 '16 at 22:05
  • update the url of [code and issue](https://github.com/cainiaofei/issueCommunicate) – nail fei Feb 16 '19 at 16:37