Java.util.concurrent.FutureTask Exception during parallel task

Hello,
We have few VM machines that we are using to execute tests parallel
During one of our stages we are getting:

an exception which occurred:
in field com.cloudbees.groovy.cps.Outcome.normal
in object com.cloudbees.groovy.cps.Outcome@6ac77b71
in field org.jenkinsci.plugins.workflow.cps.CpsThread.resumeValue
in object org.jenkinsci.plugins.workflow.cps.CpsThread@71564d60
in field org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.threads
in object org.jenkinsci.plugins.workflow.cps.CpsThreadGroup@a80d8a2
in object org.jenkinsci.plugins.workflow.cps.CpsThreadGroup@a80d8a2
Also: org.jenkinsci.plugins.workflow.actions.ErrorAction$ErrorId: 1ced049b-5ba6-43c3-ab5e-28166ec4a8f8
Also: an exception which occurred:
in field com.cloudbees.groovy.cps.Outcome.normal
in object com.cloudbees.groovy.cps.Outcome@5ee722a7
in field org.jenkinsci.plugins.workflow.cps.CpsThread.resumeValue
in object org.jenkinsci.plugins.workflow.cps.CpsThread@3f3a393
in field org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.threads
in object org.jenkinsci.plugins.workflow.cps.CpsThreadGroup@a80d8a2
in object org.jenkinsci.plugins.workflow.cps.CpsThreadGroup@a80d8a2
Also: org.jenkinsci.plugins.workflow.actions.ErrorAction$ErrorId: 419a0eb9-2050-495a-961f-b90b587d0e63
Caused: java.io.NotSerializableException: java.util.concurrent.FutureTask
Also: an exception which occurred:
in field com.cloudbees.groovy.cps.Outcome.normal
in object com.cloudbees.groovy.cps.Outcome@2d7dbaeb
in field org.jenkinsci.plugins.workflow.cps.CpsThread.resumeValue
in object org.jenkinsci.plugins.workflow.cps.CpsThread@32169e92
in field org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.threads
in object org.jenkinsci.plugins.workflow.cps.CpsThreadGroup@a80d8a2
in object org.jenkinsci.plugins.workflow.cps.CpsThreadGroup@a80d8a2
Also: org.jenkinsci.plugins.workflow.actions.ErrorAction$ErrorId: b1d25292-961f-4dd4-9e2d-a2c49339bf66
Caused: java.io.NotSerializableException: java.util.concurrent.FutureTask

This issue appears on every run in different VM.

Jenkinsfile has code:

stage(‘Run parallel’) {
steps {
script {

                def buildMap = [:]
                     [
                            'vm1', 'vm2',......
                
                    ].each {
                        buildMap[branchLabel] = executionStages(logic that is done >parallel)

parallel buildMap
}

Example Refactor

Here is an example refactor of your pipeline code to use @NonCPS and avoid non-serializable objects:

Copy codestage('Run parallel') {
    steps {
        script {
            def buildMap = [:]
            ['vm1', 'vm2', ...].each { branchLabel ->
                buildMap[branchLabel] = {
                    executionStages(branchLabel)
                }
            }
            parallel buildMap
        }
    }
}

@NonCPS
def executionStages(branchLabel) {
    // Your logic here
}