If you want one process to complete before starting the next process since the 2nd process depends on the 1st process.
Apex Flex Queues
Salesforce allowed only to have 5 concurrent batches running and
adding the 6th concurrent batch would cause the “Attempted to schedule too many concurrent batch jobs” error.
With the introduction of the Apex Flex Queues, now developers are able to submit up to 100 batches concurrently in “Holding” status and
are also able to manage the order of the queued jobs in order to control which jobs are processed first.
If the Apex flex queue has the maximum number of 100 jobs,
Database.executeBatch throws a LimitException and doesn’t add the job to the queue.
When the system has enough resources, it takes the jobs at the top of the Apex Flex Queue and places those in the Batch Job Queue with the “Queued” status.
The system is able to process up to 5 jobs concurrently.
There will be an impact to the existing queries on the AsyncApexJob object which filters records via the status field.
Earlier where queries that made use of statuses “Queued”, “Processing”, and “Preparing” would now have to also incorporate the new “Holding” status.
Eg: Select Id, Status From AsyncApexJob wHERE Status IN (‘Queued’, ‘Processing’, ‘Preparing’, ‘Holding’);
asynchronized job chaining , Like calling one batch from another.
After completing the business logic requirements, Process 1 would add Process 2 to the queue from the execute() method of the Queueable class.
In order to do this the System.enqueueJob() method would be used.
Only one Asynchronized Job can be added from an executing job via the System.enqueueJob() method.