Tread safety in smarts

In my mac an program it tries to invoke several device creation (or deletion) operations agains the smart at the same time. I figured this would be ok but it appears that ST has some thread safety issues. Some of my invocations are getting this error:

f0b4c123-781c-47de-85a9-fb13539473ea 5:18:17 PM EST: error java.lang.SecurityException: Invoking methods on class org.springframework.orm.hibernate3.HibernateOptimisticLockingFailureException is not allowed @ line 132

f0b4c123-781c-47de-85a9-fb13539473ea 5:18:17 PM EST: error Unable to delete device null for reason org.springframework.orm.hibernate3.HibernateOptimisticLockingFailureException: Object of class [physicalgraph.app.InstalledSmartApp] with identifier [f0b4c123-781c-47de-85a9-fb13539473ea]: optimistic locking failed; nested exception is org.hibernate.StaleObjectStateException: Row was updated or deleted by another transaction (or unsaved-value mapping was incorrect): [physicalgraph.app.InstalledSmartApp#f0b4c123-781c-47de-85a9-fb13539473ea]

I Figur if I’m getting hibernate errors and I’m not getting them in one-at-a-time invocations then threading issues are the likely culprit.

Any thoughts, ST?

Look at the dropcam connect app. You can find something like

device.each{
dni = get the id code here
deleteChildDevice(dni)
}