self.onmessage = function messageHandler(event) {
	var wid = event.data.wid;
	var n = event.data.start;
	var total = 0;
	var found = 0;
	var THRESHOLD = event.data.end - event.data.start;

	while (total < THRESHOLD) {
		n += 1;
		var max = Math.sqrt(n);
		var ok = true;
		
		for (var i = 2; i <= max  &&  ok; i += 1) {
			if (n % i == 0) {
				ok = false;
			}
		}
		
		if (ok) {
			found++;
		}
		
		total++;
		
		if (total % event.data.step == 0) {
			this.postMessage({wid : wid, total : total, found : found});
		}
	}
	
}
