Thread Sleep for Apex Code - Ideas - Salesforce Trailblazer Community
Trailblazer Community

All Ideas

Idea Details

Post an Idea
1,760  Points
Open
Idea has been posted. Give it an upvote or downvote.

Thread Sleep for Apex Code

Not Categorized

It would be great if we had a way of sleeping the running thread server side while we waited on something to happen inside of Apex code. When working with objects that have triggers, the triggers run separately. If those triggers update values in the objects you're working with, this won't be reflected in your code until the trigger has finished. Currently, this can be faked by going into a loop that runs until a certain time using the datetime methods. A simple method such as "sleep(milliseconds)" would solve this problem and make code more efficient on the Salesforce servers.

Merge Idea · Flag

Latest Comment from Salesforce

  • Josh Kaplan - 7 years ago

    We do not plan to offer the ability to sleep a thread.  In the mutli-tenant world, a sleeping thread is one that cannot be used by another customer.  If this happens once and again, yeah, it's fine.  But, if used poorly, this could harm our service.

    We have a very specific save order that should allow your processing to happen in serial fashion.  You can access modified values in after triggers, so there shouldn't be any benefit to sleeping a transaction.

    Regarding 3rd party limits, I don't think we would open our service up to disruption in order to comply with a 3rd party's wait restrictions.  Most of these offer bulk alternatives, and I recommend using these as best practice.

    In terms of callouts, there are some new options that are piloting in Spring '14 that will allow a sort of sleep to take place while callouts are in flight.

  • Upvotes
  • Downvotes

Ideas

Apps

from AppExchange

Questions

No results found.

Help us to keep IdeaExchange clean by pointing out overlapping ideas. We'll investigate your suggestion and merge the ideas if it makes sense.



 

 

Thanks for your merge suggestion. We will review it shortly and merge the ideas if applicable.

Salesforce takes abuse situations very seriously. Examples of abuse include but are not limited to posting of offensive language or fraudulent statements. To help us process your request as quickly as possible, please fill out the form below describing the situation. For privacy and security reasons, the final outcome of an abuse case may not be revealed to the person who reported it.


 

Thank you for your feedback. We take abuse seriously and will investigate this issue and take appropriate action.