asynchronousWait

asynchronousWait ( string _id ) : void

Wait until asynchronous finish all tasks.

See also

asynchronous
waitDelay

Example


def grade_student_class_1 = [10,12,11,9,8,0,1,20,19,14]

def grade_student_class_2 = [2,2,3,9,5,13,1]


sum_grade = 0

def datas_for_average =  // Closure wich does the sum of class grades
{def tab_grade->
	for(def grade in tab_grade)
	{
		synchronize("sum_grade",
		{->
			sum_grade+=grade
		})
	}
}

asynchronous(datas_for_average, [grade_student_class_1], 2, "datas_for_class") // Start the thread for the sum of class 1 grades
asynchronous(datas_for_average, [grade_student_class_2], 2, "datas_for_class") // Start the thread for the sum of class 2 grades

asynchronousWait("datas_for_class")

// Wait that threads with id "datas_for_class" finish for consistent datas for average calculation

average = sum_grade /(count(grade_student_class_1)+count(grade_student_class_2))

console(average)
					

Parameters

_id (optional)

Same id than in asynchronous.