@Override
	public void run() {
		// TODO Auto-generated method stub
		//ȡͻ׽Ϣ
		String clientInformation = Util.getClientInfo(clientSocket);
		Util.saveLog(clientInformation+"ӷɹǰ̵Ļ߳"+Thread.activeCount());
		//ʵ¼ɹûķ
		mo = new MonitorUserOperation(ps, br, clientSocket);
		ao = new MonitorAdminOperation(ps, br, clientSocket);
		once = OnceClass.getOnce();
		//ȡ
		while(flag){
			String mailSuffix = once.getLocalServiceInfo().getMailSuffix();
			Util.println(ps, "**********************"+once.getLocalServiceInfo().getMailSuffix().replace("@", "")+"ʼϵͳ***************************");
			Util.printlns(ps, "ѡûݣ1.û\t2.Ա\t3.˳\t");
			String choiceMenu = Util.getInput(br);
			if(choiceMenu == null){
				Util.saveLog(clientInformation+"쳣жϡ");
				return ;
			}
			if(choiceMenu.equals("1")){
				while(flag){
					//û
					Util.printlns(ps, "˵1.¼\t2.ע\t3.һ\t4.ϼ\t");
					String menu = Util.getInput(br);
					//menuΪnullû˳ý̡
					if(menu == null){
						Util.saveLog(clientInformation+"¼쳣жϡ");
						return ;
					}
					if(menu.equals("1")){
						//¼
						Util.printlns(ps, "û:");
						String userName = Util.getInput(br);
						if(userName == null){
							Util.saveLog(clientInformation+"ûʱ쳣жϡ");
							return ;
						}
						userName = userName.toLowerCase();
						//ȡuserMap
						Map<String, UserBean> userMap;
						once = OnceClass.getOnce();
						userMap= once.getUserMap();
						if(userMap.containsKey(userName) || userMap.containsKey(userName+mailSuffix)){
							if(!userName.contains(mailSuffix))
								userName += mailSuffix;
							Util.printlns(ps, ":");
							String userPass = Util.getInput(br);
							if(userPass == null){
								Util.saveLog(clientInformation+"ûʱ쳣жϡ");
								return ;
							}
							//ȡonLineMap
							Map<String, Socket> onLineMap = once.getOnLineMap();
							//ƥ
							if(userMap.get(userName).getUserPass().equals(userPass)){
								if(!onLineMap.containsKey(userName)){
									//¼ɹ
									Util.saveLog(userName+""+clientInformation+"ɹ");
									Util.println(ps, userName+""+Util.getNowTime()+"ɹ");
									//û״̬ӵonLineMap
									onLineMap.put(userName, clientSocket);
									//ɹ˵
									String runState = mo.loginSuccess(userName);
									
									if(runState.equals("NullPointerException"))
									{
										//ɾѵǳû
										Util.deleLogOutUser(userName);
										Util.saveLog(userName+""+clientInformation+"ʧ쳣жϡ");
										return ;
									}else if(runState.equals("Exit")){
										//ɾѵǳû
										Util.deleLogOutUser(userName);
										Util.saveLog(userName+""+clientInformation+"ɹǳ");
										continue;
									}
								}else{
									//ʾ쳣¼Ϣ
									Socket loginedSocket = onLineMap.get(userName);
									//
									PrintStream loginedPS = Util.getPrintStream(loginedSocket);
									String message = userName+""+Util.getClientInfo(clientSocket)+"쳣¼ʧܡ";
									Util.printlns(loginedPS, "Ҫʾ"+message);
									String message2 = Util.getClientInfo(loginedSocket);
									//½ʾ
									Util.printlns(ps, userName+""+message2+"¼");
									//־
									Util.saveLog(message+"ǰ¼Ϊ"+message2);
								}
							}else{
								Util.println(ps, "󣬷ز˵");
								continue;
							}
						}else{
							Util.println(ps, "ûڣעᡣ");
							continue;
						}
					}else if(menu.equals("2")){
						//ע
						boolean fl = mo.regeditNewUser();
						if(!fl){
							Util.saveLog(clientInformation+"עûʱ쳣жϣעʧܡ");
							return ;
						}
					}else if(menu.equals("3")){
						//һ
						boolean fl = mo.findUserPass();
						if(!fl){
							Util.saveLog(clientInformation+"ûһʱ쳣жϡ");
							return ;
						}
						
					}else if(menu.equals("4")){
						//ϼ
						break;
					}else{
						//
						continue;
					}
				}
				
			}else if(choiceMenu.equals("2")){
				//Ա
				while(flag){
					Util.printlns(ps, "˵1.¼\t2.ϼ\t");
					String menu = Util.getInput(br);
					//menuΪnullû˳ý̡
					if(menu == null){
						Util.saveLog(clientInformation+"ڹԱ¼쳣жϡ");
						return ;
					}
					if(menu.equals("1")){
						//¼
						Util.printlns(ps, "Աʺ:");
						String adminName = Util.getInput(br);
						if(adminName == null){
							Util.saveLog(clientInformation+"Աʺʱ쳣жϡ");
							return ;
						}
						if(adminName.equals(Util.ADMIN)){
							Util.printlns(ps, "Ա:");
							String adminPass = Util.getInput(br);
							if(adminPass == null){
								Util.saveLog(clientInformation+"Աʱ쳣жϡ");
								return ;
							}
							if(adminPass.equals(Util.ADMINPASS)){
								//¼ɹ
								Util.saveLog(adminName+""+clientInformation+"ɹ");
								Util.println(ps, adminName+""+Util.getNowTime()+"ɹ");
								String runState = ao.adminLoginSuccess(adminName);
								if(runState.equals("NullPointerException"))
								{
									Util.saveLog(adminName+""+clientInformation+"ʧ쳣жϡ");
									return ;
								}else if(runState.equals("Exit")){
									Util.saveLog(adminName+""+clientInformation+"ɹǳ");
									continue;
								}else{
									Util.println(ps, "󣬷ز˵");
									continue;
								}
							}else{
								Util.println(ps, "ùԱ˻ڣ롣");
								continue;
							}
						}
					}else if(menu.equals("2")){
						//ϼ
						break;
					}else{
						//
						continue;
					}
				}
			}else if(choiceMenu.equals("3")){
				//˳
				Util.saveLog(clientInformation+"˳");
				Util.println(ps, "\n\n\tڷɹϿӡرոôڡллʹá");
				return;
			}else{
				//
				continue;
			}
		}
	}