Can synchronized
be used for some of the code blocks written in lambda expression block. With respect to the following code snippet :
workflowTasks.forEach((workflowTask) -> {
String taskName = workflowTask.getTaskName();
if (profileNames.containsKey(taskName) || newSetDuplication.contains(taskName)) {
errorMessages.append(taskName + ",");
}
newSetDuplication.add(taskName);
});