⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 winner.java

📁 Java的wap push
💻 JAVA
字号:
package push;import feedback.Feedback;import java.io.*;import java.util.*;import javax.servlet.*;import javax.servlet.http.*;/** * Selects winner *  * @version 1.0 * @since 1.0 * @see Runnable */public final class Winner implements Runnable {	private final PushInitiator pusher;	private final String winnerUrl;	private final String addressType;	/**	 * Creates a new <code>Winner</code> instance.	 * 	 * @param pusher	 *            a <code>PushInitiator</code> value	 * @param winnerUrl	 *            a <code>String</code> value	 */	public Winner(PushInitiator pusher, String winnerUrl, String addressType) {		this.pusher = pusher;		this.winnerUrl = winnerUrl;		this.addressType = addressType;	}	/**	 * A checker thread selects a winner from the users that has returned	 * feedback. A winner (if any) is selected during every cycle (of the while	 * loop).	 */	public void run() {		String message = PushInitiator.createSiMessage(winnerUrl, null, null,				null, null, "You are lucky! Check the message");		while (true) {			try {				Vector users = User.getUsersOnline();				for (int i = 0; i < users.size(); i++) {					User user = (User) users.get(i);					String name = user.getName();					if (Feedback.winner().equals(name)) {						String address = user.getAddress(addressType);						if (address != null && !address.trim().equals("")) {							try {								pusher.sendPushMessage(address, addressType,										message, PushService.SI_CONTENT_TYPE);							} catch (Exception ee) {							}						}					}				}			} catch (Exception e) {				System.err.println(e);			}			try {				Thread.sleep(120000); // 2 min			} catch (InterruptedException e) {			}		}	}}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -