Question

In the Android SDK documentation, the page entitled "Using DDMS" has the following comment under the subheading "How DDMS Interacts with a Debugger":

Known debugging issues with Dalvik - Debugging an application in the Dalvik VM should work the same as it does in other VMs. However, when single-stepping out of synchronized code, the "current line" cursor may jump to the last line in the method for one step.

In this context, I've two questions:

a) I'm not sure what "synchronized code" refers too? Are we talking about "debug" code or code using the "synchronized" keyword, or something else? I'm lacking a definition on the page, and synchronized is a generic term so it's not clear to me where the limitation actually lies.

b) Depending on the answer from "b", I suspect my second question would be what does stepping "out" of synchronized code mean?

Your help in explaining this would be appreciated with thanks.

Était-ce utile?

La solution

I believe they simply meant "synchronous code". Asynchronous code might jump to other threads as the scheduler sees fit, but synchronous code should proceed in order. They have mentioned a known peculiarity with the Dalvik debugger, that it makes a seemingly inexplicable jump when it should step from one line of execution to the next. That issue has actually confused me once or twice...

Autres conseils

synchronized is a keyword you may use either on methods or on blocks. It is helpful when using threads.

Synchronized methods enable a simple strategy for preventing thread interference and memory consistency errors: if an object is visible to more than one thread, all reads or writes to that object's variables are done through synchronized methods.

http://docs.oracle.com/javase/tutorial/essential/concurrency/syncmeth.html

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top