Revert "Remove all locks in matlab dlg."

This reverts commit cd4e123721421af07f4b4a2b6ba3b7972e984307.
Revert "Revert "Remove all locks in matlab dlg.""

This reverts commit 1692e5bb8321845c1ce46f7b06b8f617b1a4b002.
Revert "Revert "Revert "Remove all locks in matlab dlg."""

This reverts commit f64385b0fa7b61cfc603ecd5d316332317e33c90.
Add lock back.