多线程

wylc123 1年前 ⋅ 512 阅读
public static void main(String[] args) {
		/*切分词工作线程*/
		class ModelIdentifyWorkThread extends Thread {
			String msg;
			public ModelIdentifyWorkThread(String msg) {
				super();
				this.msg = msg;
			}
			public void run() {
				try {
					int count = 0;
					while (true){
						System.out.println(msg+count);
						if(count == 50){
							Thread.sleep(5000);
						}
						count ++;
					}
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		}
		ModelIdentifyWorkThread x = new ModelIdentifyWorkThread("大傻子");
		x.start();
	}

全部评论: 0

    我有话说: