javapns/src/main/java/javapns/notification/transmission/NotificationThreads.java
/**
	 * Create group of devices ready to be dispatched to worker threads.
	 * 
	 * @param devices a large list of devices
	 * @param threads the number of threads to group devices for
	 * @return
	 */
Create group of devices ready to be dispatched to worker threads.

@param devices a large list of devices
@param threads the number of threads to group devices for
@return
Create group of devices ready to be dispatched to worker threads . @param devices a large list of devices @param threads the number of threads to group devices for @return
private static List<List<Device>> groupDevices(List<Device> devices, int threads) {
		List<List<Device>> groups = new Vector<List<Device>>(threads);
		int total = devices.size();
		int devicesPerThread = (total / threads);
		if (total % threads > 0) devicesPerThread++;
		for (int i = 0; i < threads; i++) {
			int firstDevice = i * devicesPerThread;
			if (firstDevice >= total) break;
			int lastDevice = firstDevice + devicesPerThread - 1;
			if (lastDevice >= total) lastDevice = total - 1;
			lastDevice++;
			List<Device> threadDevices = devices.subList(firstDevice, lastDevice);
			groups.add(threadDevices);
		}
		return groups;
	}
private static List < List < Device > > groupDevices ( List < Device > devices , int threads ) { List < List < Device > > groups = new Vector < List < Device > > ( threads ) ; int total = devices . size ( ) ; int devicesPerThread = ( total / threads ) ; if ( total % threads > 0 ) devicesPerThread ++ ; for ( int i = 0 ; i < threads ; i ++ ) { int firstDevice = i * devicesPerThread ; if ( firstDevice >= total ) break ; int lastDevice = firstDevice + devicesPerThread - 1 ; if ( lastDevice >= total ) lastDevice = total - 1 ; lastDevice ++ ; List < Device > threadDevices = devices . subList ( firstDevice , lastDevice ) ; groups . add ( threadDevices ) ; } return groups ; }
Create group of devices ready to be dispatched to worker threads.
Create group of devices ready to be dispatched to worker threads .
//System.out.println("Making "+threads+" groups of "+devicesPerThread+" devices out of "+total+" devices in total"); //System.out.println("Grouping together "+(lastDevice-firstDevice)+" devices (#"+firstDevice+" to "+lastDevice+")");