Run code in separate thread under admin in five seconds

Run code in separate thread under admin
Boolean fake = (Boolean) AuthenticationUtil.runAs(new AuthenticationUtil.RunAsWork() {
            @Override
            public Boolean doWork() throws FileExistsException, FileNotFoundException {

                   // your code here

                   return true;
                  }
            }, "admin");

Run code in transaction
https://forums.alfresco.com/forum/developer-discussions/repository-services/how-write-code-transactions-06242008-0941
transactionService.getRetryingTransactionHelper().doInTransaction(
                            new RetryingTransactionHelper.RetryingTransactionCallback<boolean>() {
                                public Boolean execute() throws Throwable {

                                    // your code here

                                    return true;
                                }
                            });
Run code in separate thread in 5 seconds
final ScheduledThreadPoolExecutor executor = new ScheduledThreadPoolExecutor(1);
        executor.schedule(myThread, 5, TimeUnit.SECONDS);

No comments:

Post a Comment