{"id":674,"date":"2016-05-21T19:22:22","date_gmt":"2016-05-21T19:22:22","guid":{"rendered":"http:\/\/blogs.softwareclue.com\/?p=674"},"modified":"2016-05-21T19:22:22","modified_gmt":"2016-05-21T19:22:22","slug":"%e8%af%a6%e8%a7%a3java%e5%ae%9a%e6%97%b6%e4%bb%bb%e5%8a%a1-2","status":"publish","type":"post","link":"http:\/\/blog.softwareclues.com\/zh\/%e8%af%a6%e8%a7%a3java%e5%ae%9a%e6%97%b6%e4%bb%bb%e5%8a%a1-2","title":{"rendered":"\u8be6\u89e3Java\u5b9a\u65f6\u4efb\u52a1"},"content":{"rendered":"<blockquote><p><strong>\u6765\u81ea\uff1a\u535a\u5ba2\u56ed<\/strong><\/p>\n<p><strong>\u4f5c\u8005\uff1a chenssy\u00a0<\/strong><\/p>\n<p><strong>\u94fe\u63a5\uff1a\u00a0http:\/\/www.cn<\/strong><strong>blogs.com\/chenssy\/p\/3788407.html<\/strong><\/p><\/blockquote>\n<p>\u5728\u6211\u4eec\u7f16\u7a0b\u8fc7\u7a0b\u4e2d\u5982\u679c\u9700\u8981\u6267\u884c\u4e00\u4e9b\u7b80\u5355\u7684\u5b9a\u65f6\u4efb\u52a1\uff0c\u65e0\u987b\u505a\u590d\u6742\u7684\u63a7\u5236\uff0c\u6211\u4eec\u53ef\u4ee5\u8003\u8651\u4f7f\u7528JDK\u4e2d\u7684Timer\u5b9a\u65f6\u4efb\u52a1\u6765\u5b9e\u73b0\u3002\u4e0b\u9762LZ\u5c31\u5176\u539f\u7406\u3001\u5b9e\u4f8b\u4ee5\u53caTimer\u7f3a\u9677\u4e09\u4e2a\u65b9\u9762\u6765\u89e3\u6790Java Timer\u5b9a\u65f6\u5668\u3002<\/p>\n<p><strong>\u4e00\u3001\u7b80\u4ecb<\/strong><\/p>\n<p>\u5728Java\u4e2d\u4e00\u4e2a\u5b8c\u6574\u5b9a\u65f6\u4efb\u52a1\u9700\u8981\u7531Timer\u3001TimerTask\u4e24\u4e2a\u7c7b\u6765\u914d\u5408\u5b8c\u6210\u3002 API\u4e2d\u662f\u8fd9\u6837\u5b9a\u4e49\u4ed6\u4eec\u7684\uff0cTimer\uff1a\u4e00\u79cd\u5de5\u5177\uff0c\u7ebf\u7a0b\u7528\u5176\u5b89\u6392\u4ee5\u540e\u5728\u540e\u53f0\u7ebf\u7a0b\u4e2d\u6267\u884c\u7684\u4efb\u52a1\u3002\u53ef\u5b89\u6392\u4efb\u52a1\u6267\u884c\u4e00\u6b21\uff0c\u6216\u8005\u5b9a\u671f\u91cd\u590d\u6267\u884c\u3002\u7531TimerTask\uff1aTimer \u5b89\u6392\u4e3a\u4e00\u6b21\u6267\u884c\u6216\u91cd\u590d\u6267\u884c\u7684\u4efb\u52a1\u3002\u6211\u4eec\u53ef\u4ee5\u8fd9\u6837\u7406\u89e3Timer\u662f\u4e00\u79cd\u5b9a\u65f6\u5668\u5de5\u5177\uff0c\u7528\u6765\u5728\u4e00\u4e2a\u540e\u53f0\u7ebf\u7a0b\u8ba1\u5212\u6267\u884c\u6307\u5b9a\u4efb\u52a1\uff0c\u800cTimerTask\u4e00\u4e2a\u62bd\u8c61\u7c7b\uff0c\u5b83\u7684\u5b50\u7c7b\u4ee3\u8868\u4e00\u4e2a\u53ef\u4ee5\u88abTimer\u8ba1\u5212\u7684\u4efb\u52a1\u3002<\/p>\n<p><strong>Timer\u7c7b<\/strong><\/p>\n<p>\u5728\u5de5\u5177\u7c7bTimer\u4e2d\uff0c\u63d0\u4f9b\u4e86\u56db\u4e2a\u6784\u9020\u65b9\u6cd5\uff0c\u6bcf\u4e2a\u6784\u9020\u65b9\u6cd5\u90fd\u542f\u52a8\u4e86\u8ba1\u65f6\u5668\u7ebf\u7a0b\uff0c\u540c\u65f6Timer\u7c7b\u53ef\u4ee5\u4fdd\u8bc1\u591a\u4e2a\u7ebf\u7a0b\u53ef\u4ee5\u5171\u4eab\u5355\u4e2aTimer\u5bf9\u8c61\u800c\u65e0\u9700\u8fdb\u884c\u5916\u90e8\u540c\u6b65\uff0c\u6240\u4ee5Timer\u7c7b\u662f\u7ebf\u7a0b\u5b89\u5168\u7684\u3002\u4f46\u662f\u7531\u4e8e\u6bcf\u4e00\u4e2aTimer\u5bf9\u8c61\u5bf9\u5e94\u7684\u662f\u5355\u4e2a\u540e\u53f0\u7ebf\u7a0b\uff0c\u7528\u4e8e\u987a\u5e8f\u6267\u884c\u6240\u6709\u7684\u8ba1\u65f6\u5668\u4efb\u52a1\uff0c\u4e00\u822c\u60c5\u51b5\u4e0b\u6211\u4eec\u7684\u7ebf\u7a0b\u4efb\u52a1\u6267\u884c\u6240\u6d88\u8017\u7684\u65f6\u95f4\u5e94\u8be5\u975e\u5e38\u77ed\uff0c\u4f46\u662f\u7531\u4e8e\u7279\u6b8a\u60c5\u51b5\u5bfc\u81f4\u67d0\u4e2a\u5b9a\u65f6\u5668\u4efb\u52a1\u6267\u884c\u7684\u65f6\u95f4\u592a\u957f\uff0c\u90a3\u4e48\u4ed6\u5c31\u4f1a\u201c\u72ec\u5360\u201d\u8ba1\u65f6\u5668\u7684\u4efb\u52a1\u6267\u884c\u7ebf\u7a0b\uff0c\u5176\u540e\u7684\u6240\u6709\u7ebf\u7a0b\u90fd\u5fc5\u987b\u7b49\u5f85\u5b83\u6267\u884c\u5b8c\uff0c\u8fd9\u5c31\u4f1a\u5ef6\u8fdf\u540e\u7eed\u4efb\u52a1\u7684\u6267\u884c\uff0c\u4f7f\u8fd9\u4e9b\u4efb\u52a1\u5806\u79ef\u5728\u4e00\u8d77\uff0c\u5177\u4f53\u60c5\u51b5\u6211\u4eec\u540e\u9762\u5206\u6790\u3002<\/p>\n<p>\u5f53\u7a0b\u5e8f\u521d\u59cb\u5316\u5b8c\u6210Timer\u540e\uff0c\u5b9a\u65f6\u4efb\u52a1\u5c31\u4f1a\u6309\u7167\u6211\u4eec\u8bbe\u5b9a\u7684\u65f6\u95f4\u53bb\u6267\u884c\uff0cTimer\u63d0\u4f9b\u4e86schedule\u65b9\u6cd5\uff0c\u8be5\u65b9\u6cd5\u6709\u591a\u4e2d\u91cd\u8f7d\u65b9\u5f0f\u6765\u9002\u5e94\u4e0d\u540c\u7684\u60c5\u51b5\uff0c\u5982\u4e0b\uff1a<\/p>\n<p>schedule(TimerTask task, Date time)\uff1a\u5b89\u6392\u5728\u6307\u5b9a\u7684\u65f6\u95f4\u6267\u884c\u6307\u5b9a\u7684\u4efb\u52a1\u3002<\/p>\n<p>schedule(TimerTask task, Date firstTime, long period) \uff1a\u5b89\u6392\u6307\u5b9a\u7684\u4efb\u52a1\u5728\u6307\u5b9a\u7684\u65f6\u95f4\u5f00\u59cb\u8fdb\u884c\u91cd\u590d\u7684\u56fa\u5b9a\u5ef6\u8fdf\u6267\u884c\u3002<\/p>\n<p>schedule(TimerTask task, long delay) \uff1a\u5b89\u6392\u5728\u6307\u5b9a\u5ef6\u8fdf\u540e\u6267\u884c\u6307\u5b9a\u7684\u4efb\u52a1\u3002<\/p>\n<p>schedule(TimerTask task, long delay, long period) \uff1a\u5b89\u6392\u6307\u5b9a\u7684\u4efb\u52a1\u4ece\u6307\u5b9a\u7684\u5ef6\u8fdf\u540e\u5f00\u59cb\u8fdb\u884c\u91cd\u590d\u7684\u56fa\u5b9a\u5ef6\u8fdf\u6267\u884c\u3002<\/p>\n<p>\u540c\u65f6\u4e5f\u91cd\u8f7d\u4e86scheduleAtFixedRate\u65b9\u6cd5\uff0cscheduleAtFixedRate\u65b9\u6cd5\u4e0eschedule\u76f8\u540c\uff0c\u53ea\u4e0d\u8fc7\u4ed6\u4eec\u7684\u4fa7\u91cd\u70b9\u4e0d\u540c\uff0c\u533a\u522b\u540e\u9762\u5206\u6790\u3002<\/p>\n<p>scheduleAtFixedRate(TimerTask task, Date firstTime, long period)\uff1a\u5b89\u6392\u6307\u5b9a\u7684\u4efb\u52a1\u5728\u6307\u5b9a\u7684\u65f6\u95f4\u5f00\u59cb\u8fdb\u884c\u91cd\u590d\u7684\u56fa\u5b9a\u901f\u7387\u6267\u884c\u3002<\/p>\n<p>scheduleAtFixedRate(TimerTask task, long delay, long period)\uff1a\u5b89\u6392\u6307\u5b9a\u7684\u4efb\u52a1\u5728\u6307\u5b9a\u7684\u5ef6\u8fdf\u540e\u5f00\u59cb\u8fdb\u884c\u91cd\u590d\u7684\u56fa\u5b9a\u901f\u7387\u6267\u884c\u3002<\/p>\n<p><strong>TimerTask<\/strong><\/p>\n<p>TimerTask\u7c7b\u662f\u4e00\u4e2a\u62bd\u8c61\u7c7b\uff0c\u7531Timer \u5b89\u6392\u4e3a\u4e00\u6b21\u6267\u884c\u6216\u91cd\u590d\u6267\u884c\u7684\u4efb\u52a1\u3002\u5b83\u6709\u4e00\u4e2a\u62bd\u8c61\u65b9\u6cd5run()\u65b9\u6cd5\uff0c\u8be5\u65b9\u6cd5\u7528\u4e8e\u6267\u884c\u76f8\u5e94\u8ba1\u65f6\u5668\u4efb\u52a1\u8981\u6267\u884c\u7684\u64cd\u4f5c\u3002\u56e0\u6b64\u6bcf\u4e00\u4e2a\u5177\u4f53\u7684\u4efb\u52a1\u7c7b\u90fd\u5fc5\u987b\u7ee7\u627fTimerTask\uff0c\u7136\u540e\u91cd\u5199run()\u65b9\u6cd5\u3002<\/p>\n<p>\u53e6\u5916\u5b83\u8fd8\u6709\u4e24\u4e2a\u975e\u62bd\u8c61\u7684\u65b9\u6cd5\uff1a<\/p>\n<p>boolean cancel()\uff1a\u53d6\u6d88\u6b64\u8ba1\u65f6\u5668\u4efb\u52a1\u3002<\/p>\n<p>long scheduledExecutionTime()\uff1a\u8fd4\u56de\u6b64\u4efb\u52a1\u6700\u8fd1\u5b9e\u9645\u6267\u884c\u7684\u5b89\u6392\u6267\u884c\u65f6\u95f4\u3002<\/p>\n<p><strong>\u4e8c\u3001\u5b9e\u4f8b<\/strong><\/p>\n<p><strong>2.1\u3001\u6307\u5b9a\u5ef6\u8fdf\u65f6\u95f4\u6267\u884c\u5b9a\u65f6\u4efb\u52a1<\/strong><\/p>\n<blockquote><p>public class TimerTest01 {<\/p>\n<p>Timer timer;<\/p>\n<p>public TimerTest01(int time){<\/p>\n<p>timer = new Timer();<\/p>\n<p>timer.schedule(new TimerTaskTest01(), time * 1000);<\/p>\n<p>}<\/p>\n<p>public static void main(String[] args) {<\/p>\n<p>System.out.println(&#8220;timer begin&#8230;.&#8221;);<\/p>\n<p>new TimerTest01(3);<\/p>\n<p>}<\/p>\n<p>}<\/p>\n<p>public class TimerTaskTest01 extends TimerTask{<\/p>\n<p>public void run() {<\/p>\n<p>System.out.println(&#8220;Time&#8217;s up!!!!&#8221;);<\/p>\n<p>}<\/p>\n<p>}<\/p><\/blockquote>\n<p>\u8fd0\u884c\u7ed3\u679c\uff1a<\/p>\n<p>\u9996\u5148\u6253\u5370\uff1atimer begin&#8230;.3\u79d2\u540e\u6253\u5370\uff1aTime&#8217;s up!!!!<\/p>\n<p><strong>2.2\u3001\u5728\u6307\u5b9a\u65f6\u95f4\u6267\u884c\u5b9a\u65f6\u4efb\u52a1<\/strong><\/p>\n<blockquote><p>public class TimerTest02 {<\/p>\n<p>Timer timer;<\/p>\n<p>public TimerTest02(){<\/p>\n<p>Date time = getTime();<\/p>\n<p>System.out.println(&#8220;\u6307\u5b9a\u65f6\u95f4time=&#8221; + time);<\/p>\n<p>timer = new Timer();<\/p>\n<p>timer.schedule(new TimerTaskTest02(), time);<\/p>\n<p>}<\/p>\n<p>public Date getTime(){<\/p>\n<p>Calendar calendar = Calendar.getInstance();<\/p>\n<p>calendar.set(Calendar.HOUR_OF_DAY, 11);<\/p>\n<p>calendar.set(Calendar.MINUTE, 39);<\/p>\n<p>calendar.set(Calendar.SECOND, 00);<\/p>\n<p>Date time = calendar.getTime();<\/p>\n<p>return time;<\/p>\n<p>}<\/p>\n<p>public static void main(String[] args) {<\/p>\n<p>new TimerTest02();<\/p>\n<p>}<\/p>\n<p>}<\/p>\n<p>public class TimerTaskTest02 extends TimerTask{<\/p>\n<p>@Override<\/p>\n<p>public void run() {<\/p>\n<p>System.out.println(&#8220;\u6307\u5b9a\u65f6\u95f4\u6267\u884c\u7ebf\u7a0b\u4efb\u52a1&#8230;&#8221;);<\/p>\n<p>}<\/p>\n<p>}<\/p><\/blockquote>\n<p>\u5f53\u65f6\u95f4\u5230\u8fbe11:39:00\u65f6\u5c31\u4f1a\u6267\u884c\u8be5\u7ebf\u7a0b\u4efb\u52a1\uff0c\u5f53\u7136\u5927\u4e8e\u8be5\u65f6\u95f4\u4e5f\u4f1a\u6267\u884c\uff01\uff01\u6267\u884c\u7ed3\u679c\u4e3a\uff1a<\/p>\n<p>\u6307\u5b9a\u65f6\u95f4time=Tue Jun 10 11:39:00 CST 2014\u6307\u5b9a\u65f6\u95f4\u6267\u884c\u7ebf\u7a0b\u4efb\u52a1&#8230;<\/p>\n<p><strong>2.3\u3001\u5728\u5ef6\u8fdf\u6307\u5b9a\u65f6\u95f4\u540e\u4ee5\u6307\u5b9a\u7684\u95f4\u9694\u65f6\u95f4\u5faa\u73af\u6267\u884c\u5b9a\u65f6\u4efb\u52a1<\/strong><\/p>\n<blockquote><p>public class TimerTest03 {<\/p>\n<p>Timer timer;<\/p>\n<p>public TimerTest03(){<\/p>\n<p>timer = new Timer();<\/p>\n<p>timer.schedule(new TimerTaskTest03(), 1000, 2000);<\/p>\n<p>}<\/p>\n<p>public static void main(String[] args) {<\/p>\n<p>new TimerTest03();<\/p>\n<p>}<\/p>\n<p>}<\/p>\n<p>public class TimerTaskTest03 extends TimerTask{<\/p>\n<p>@Override<\/p>\n<p>public void run() {<\/p>\n<p>Date date = new Date(this.scheduledExecutionTime());<\/p>\n<p>System.out.println(&#8220;\u672c\u6b21\u6267\u884c\u8be5\u7ebf\u7a0b\u7684\u65f6\u95f4\u4e3a\uff1a&#8221; + date);<\/p>\n<p>}<\/p>\n<p>}<\/p><\/blockquote>\n<p><strong>\u8fd0\u884c\u7ed3\u679c:<\/strong><\/p>\n<blockquote><p>\u672c\u6b21\u6267\u884c\u8be5\u7ebf\u7a0b\u7684\u65f6\u95f4\u4e3a\uff1aTue Jun 10 21:19:47 CST 2014\u672c\u6b21\u6267\u884c\u8be5\u7ebf\u7a0b\u7684\u65f6\u95f4\u4e3a\uff1aTue Jun 10 21:19:49 CST 2014\u672c\u6b21\u6267\u884c\u8be5\u7ebf\u7a0b\u7684\u65f6\u95f4\u4e3a\uff1aTue Jun 10 21:19:51 CST 2014\u672c\u6b21\u6267\u884c\u8be5\u7ebf\u7a0b\u7684\u65f6\u95f4\u4e3a\uff1aTue Jun 10 21:19:53 CST 2014\u672c\u6b21\u6267\u884c\u8be5\u7ebf\u7a0b\u7684\u65f6\u95f4\u4e3a\uff1aTue Jun 10 21:19:55 CST 2014\u672c\u6b21\u6267\u884c\u8be5\u7ebf\u7a0b\u7684\u65f6\u95f4\u4e3a\uff1aTue Jun 10 21:19:57 CST 2014&#8230;&#8230;&#8230;&#8230;&#8230;..<\/p><\/blockquote>\n<p>\u5bf9\u4e8e\u8fd9\u4e2a\u7ebf\u7a0b\u4efb\u52a1,\u5982\u679c\u6211\u4eec\u4e0d\u5c06\u8be5\u4efb\u52a1\u505c\u6b62,\u4ed6\u4f1a\u4e00\u76f4\u8fd0\u884c\u4e0b\u53bb\u3002<\/p>\n<p>\u5bf9\u4e8e\u4e0a\u9762\u4e09\u4e2a\u5b9e\u4f8b\uff0cLZ\u53ea\u662f\u7b80\u5355\u7684\u6f14\u793a\u4e86\u4e00\u4e0b\uff0c\u540c\u65f6\u4e5f\u6ca1\u6709\u8bb2\u89e3scheduleAtFixedRate\u65b9\u6cd5\u7684\u4f8b\u5b50\uff0c\u5176\u5b9e\u8be5\u65b9\u6cd5\u4e0eschedule\u65b9\u6cd5\u4e00\u6837\uff01<\/p>\n<p><strong>2.4\u3001\u5206\u6790schedule\u548cscheduleAtFixedRate<\/strong><\/p>\n<p>1\u3001schedule(TimerTask task, Date time)\u3001schedule(TimerTask task, long delay)<\/p>\n<p>\u5bf9\u4e8e\u8fd9\u4e24\u4e2a\u65b9\u6cd5\u800c\u8a00\uff0c\u5982\u679c\u6307\u5b9a\u7684\u8ba1\u5212\u6267\u884c\u65f6\u95f4scheduledExecutionTime&lt;= systemCurrentTime\uff0c\u5219task\u4f1a\u88ab\u7acb\u5373\u6267\u884c\u3002scheduledExecutionTime\u4e0d\u4f1a\u56e0\u4e3a\u67d0\u4e00\u4e2atask\u7684\u8fc7\u5ea6\u6267\u884c\u800c\u6539\u53d8\u3002<\/p>\n<p>2\u3001schedule(TimerTask task, Date firstTime, long period)\u3001schedule(TimerTask task, long delay, long period)<\/p>\n<p>\u8fd9\u4e24\u4e2a\u65b9\u6cd5\u4e0e\u4e0a\u9762\u4e24\u4e2a\u5c31\u6709\u70b9\u513f\u4e0d\u540c\u7684\uff0c\u524d\u9762\u63d0\u8fc7Timer\u7684\u8ba1\u65f6\u5668\u4efb\u52a1\u4f1a\u56e0\u4e3a\u524d\u4e00\u4e2a\u4efb\u52a1\u6267\u884c\u65f6\u95f4\u8f83\u957f\u800c\u5ef6\u65f6\u3002\u5728\u8fd9\u4e24\u4e2a\u65b9\u6cd5\u4e2d\uff0c\u6bcf\u4e00\u6b21\u6267\u884c\u7684task\u7684\u8ba1\u5212\u65f6\u95f4\u4f1a\u968f\u7740\u524d\u4e00\u4e2atask\u7684\u5b9e\u9645\u65f6\u95f4\u800c\u53d1\u751f\u6539\u53d8\uff0c\u4e5f\u5c31\u662fscheduledExecutionTime(n+1)=realExecutionTime(n)+periodTime\u3002\u4e5f\u5c31\u662f\u8bf4\u5982\u679c\u7b2cn\u4e2atask\u7531\u4e8e\u67d0\u79cd\u60c5\u51b5\u5bfc\u81f4\u8fd9\u6b21\u7684\u6267\u884c\u65f6\u95f4\u8fc7\u7a0b\uff0c\u6700\u540e\u5bfc\u81f4systemCurrentTime&gt;= scheduledExecutionTime(n+1)\uff0c\u8fd9\u662f\u7b2cn+1\u4e2atask\u5e76\u4e0d\u4f1a\u56e0\u4e3a\u5230\u65f6\u4e86\u800c\u6267\u884c\uff0c\u4ed6\u4f1a\u7b49\u5f85\u7b2cn\u4e2atask\u6267\u884c\u5b8c\u4e4b\u540e\u518d\u6267\u884c\uff0c\u90a3\u4e48\u8fd9\u6837\u52bf\u5fc5\u4f1a\u5bfc\u81f4n+2\u4e2a\u7684\u6267\u884c\u5b9e\u73b0scheduledExecutionTime\u653e\u751f\u6539\u53d8\u5373scheduledExecutionTime(n+2) = realExecutionTime(n+1)+periodTime\u3002\u6240\u4ee5\u8fd9\u4e24\u4e2a\u65b9\u6cd5\u66f4\u52a0\u6ce8\u91cd\u4fdd\u5b58\u95f4\u9694\u65f6\u95f4\u7684\u7a33\u5b9a\u3002<\/p>\n<p>3\u3001scheduleAtFixedRate(TimerTask task, Date firstTime, long period)\u3001scheduleAtFixedRate(TimerTask task, long delay, long period)<\/p>\n<p>\u5728\u524d\u9762\u4e5f\u63d0\u8fc7scheduleAtFixedRate\u4e0eschedule\u65b9\u6cd5\u7684\u4fa7\u91cd\u70b9\u4e0d\u540c\uff0cschedule\u65b9\u6cd5\u4fa7\u91cd\u4fdd\u5b58\u95f4\u9694\u65f6\u95f4\u7684\u7a33\u5b9a\uff0c\u800cscheduleAtFixedRate\u65b9\u6cd5\u66f4\u52a0\u4fa7\u91cd\u4e8e\u4fdd\u6301\u6267\u884c\u9891\u7387\u7684\u7a33\u5b9a\u3002\u4e3a\u4ec0\u4e48\u8fd9\u4e48\u8bf4\uff0c\u539f\u56e0\u5982\u4e0b\u3002\u5728schedule\u65b9\u6cd5\u4e2d\u4f1a\u56e0\u4e3a\u524d\u4e00\u4e2a\u4efb\u52a1\u7684\u5ef6\u8fdf\u800c\u5bfc\u81f4\u5176\u540e\u9762\u7684\u5b9a\u65f6\u4efb\u52a1\u5ef6\u65f6\uff0c\u800cscheduleAtFixedRate\u65b9\u6cd5\u5219\u4e0d\u4f1a\uff0c\u5982\u679c\u7b2cn\u4e2atask\u6267\u884c\u65f6\u95f4\u8fc7\u957f\u5bfc\u81f4systemCurrentTime&gt;= scheduledExecutionTime(n+1)\uff0c\u5219\u4e0d\u4f1a\u505a\u4efb\u4f55\u7b49\u5f85\u4ed6\u4f1a\u7acb\u5373\u6267\u884c\u7b2cn+1\u4e2atask\uff0c\u6240\u4ee5scheduleAtFixedRate\u65b9\u6cd5\u6267\u884c\u65f6\u95f4\u7684\u8ba1\u7b97\u65b9\u6cd5\u4e0d\u540c\u4e8eschedule\uff0c\u800c\u662fscheduledExecutionTime(n)=firstExecuteTime +n*periodTime\uff0c\u8be5\u8ba1\u7b97\u65b9\u6cd5\u6c38\u8fdc\u4fdd\u6301\u4e0d\u53d8\u3002\u6240\u4ee5scheduleAtFixedRate\u66f4\u52a0\u4fa7\u91cd\u4e8e\u4fdd\u6301\u6267\u884c\u9891\u7387\u7684\u7a33\u5b9a\u3002<\/p>\n<p><strong>\u4e09\u3001Timer\u7684\u7f3a\u9677<\/strong><\/p>\n<p><strong>3.1\u3001Timer\u7684\u7f3a\u9677<\/strong><\/p>\n<p>Timer\u8ba1\u65f6\u5668\u53ef\u4ee5\u5b9a\u65f6\uff08\u6307\u5b9a\u65f6\u95f4\u6267\u884c\u4efb\u52a1\uff09\u3001\u5ef6\u8fdf\uff08\u5ef6\u8fdf5\u79d2\u6267\u884c\u4efb\u52a1\uff09\u3001\u5468\u671f\u6027\u5730\u6267\u884c\u4efb\u52a1\uff08\u6bcf\u9694\u4e2a1\u79d2\u6267\u884c\u4efb\u52a1\uff09\uff0c\u4f46\u662f\uff0cTimer\u5b58\u5728\u4e00\u4e9b\u7f3a\u9677\u3002\u9996\u5148Timer\u5bf9\u8c03\u5ea6\u7684\u652f\u6301\u662f\u57fa\u4e8e\u7edd\u5bf9\u65f6\u95f4\u7684\uff0c\u800c\u4e0d\u662f\u76f8\u5bf9\u65f6\u95f4\uff0c\u6240\u4ee5\u5b83\u5bf9\u7cfb\u7edf\u65f6\u95f4\u7684\u6539\u53d8\u975e\u5e38\u654f\u611f\u3002\u5176\u6b21Timer\u7ebf\u7a0b\u662f\u4e0d\u4f1a\u6355\u83b7\u5f02\u5e38\u7684\uff0c\u5982\u679cTimerTask\u629b\u51fa\u7684\u4e86\u672a\u68c0\u67e5\u5f02\u5e38\u5219\u4f1a\u5bfc\u81f4Timer\u7ebf\u7a0b\u7ec8\u6b62\uff0c\u540c\u65f6Timer\u4e5f\u4e0d\u4f1a\u91cd\u65b0\u6062\u590d\u7ebf\u7a0b\u7684\u6267\u884c\uff0c\u4ed6\u4f1a\u9519\u8bef\u7684\ufffd\ufffd\ufffd\u4e3a\u6574\u4e2aTimer\u7ebf\u7a0b\u90fd\u4f1a\u53d6\u6d88\u3002\u540c\u65f6\uff0c\u5df2\u7ecf\u88ab\u5b89\u6392\u5355\u5c1a\u672a\u6267\u884c\u7684TimerTask\u4e5f\u4e0d\u4f1a\u518d\u6267\u884c\u4e86\uff0c\u65b0\u7684\u4efb\u52a1\u4e5f\u4e0d\u80fd\u88ab\u8c03\u5ea6\u3002\u6545\u5982\u679cTimerTask\u629b\u51fa\u672a\u68c0\u67e5\u7684\u5f02\u5e38\uff0cTimer\u5c06\u4f1a\u4ea7\u751f\u65e0\u6cd5\u9884\u6599\u7684\u884c\u4e3a\u3002<\/p>\n<p>1\u3001Timer\u7ba1\u7406\u65f6\u95f4\u5ef6\u8fdf\u7f3a\u9677<\/p>\n<p>\u524d\u9762Timer\u5728\u6267\u884c\u5b9a\u65f6\u4efb\u52a1\u65f6\u53ea\u4f1a\u521b\u5efa\u4e00\u4e2a\u7ebf\u7a0b\u4efb\u52a1\uff0c\u5982\u679c\u5b58\u5728\u591a\u4e2a\u7ebf\u7a0b\uff0c\u82e5\u5176\u4e2d\u67d0\u4e2a\u7ebf\u7a0b\u56e0\u4e3a\u67d0\u79cd\u539f\u56e0\u800c\u5bfc\u81f4\u7ebf\u7a0b\u4efb\u52a1\u6267\u884c\u65f6\u95f4\u8fc7\u957f\uff0c\u8d85\u8fc7\u4e86\u4e24\u4e2a\u4efb\u52a1\u7684\u95f4\u9694\u65f6\u95f4\uff0c\u4f1a\u53d1\u751f\u4e00\u4e9b\u7f3a\u9677\uff1a<\/p>\n<blockquote><p>public class TimerTest04 {<\/p>\n<p>private Timer timer;<\/p>\n<p>public long start;<\/p>\n<p>public TimerTest04(){<\/p>\n<p>this.timer = new Timer();<\/p>\n<p>start = System.currentTimeMillis();<\/p>\n<p>}<\/p>\n<p>public void timerOne(){<\/p>\n<p>timer.schedule(new TimerTask() {<\/p>\n<p>public void run() {<\/p>\n<p>System.out.println(&#8220;timerOne invoked ,the time:&#8221; + (System.currentTimeMillis() &#8211; start));<\/p>\n<p>try {<\/p>\n<p>Thread.sleep(4000);<\/p>\n<p>\/\/\u7ebf\u7a0b\u4f11\u77203000<\/p>\n<p>}<\/p>\n<p>catch (InterruptedException e) {<\/p>\n<p>e.printStackTrace();<\/p>\n<p>}<\/p>\n<p>}<\/p>\n<p>}, 1000);<\/p>\n<p>}<\/p>\n<p>public void timerTwo(){<\/p>\n<p>timer.schedule(new TimerTask() {<\/p>\n<p>public void run() {<\/p>\n<p>System.out.println(&#8220;timerOne invoked ,the time:&#8221; + (System.currentTimeMillis() &#8211; start));<\/p>\n<p>}<\/p>\n<p>}, 3000);<\/p>\n<p>}<\/p>\n<p>public static void main(String[] args) throws Exception {<\/p>\n<p>TimerTest04 test = new TimerTest04();<\/p>\n<p>test.timerOne();<\/p>\n<p>test.timerTwo();<\/p>\n<p>}<\/p>\n<p>}<\/p><\/blockquote>\n<p>\u6309\u7167\u6211\u4eec\u6b63\u5e38\u601d\u8def\uff0ctimerTwo\u5e94\u8be5\u662f\u57283s\u540e\u6267\u884c\uff0c\u5176\u7ed3\u679c\u5e94\u8be5\u662f\uff1a<\/p>\n<p>timerOne invoked ,the time:1001timerOne invoked ,the time:3001<\/p>\n<p>\u4f46\u662f\u4e8b\u4e0e\u613f\u8fdd\uff0ctimerOne\u7531\u4e8esleep(4000)\uff0c\u4f11\u7720\u4e864S\uff0c\u540c\u65f6Timer\u5185\u90e8\u662f\u4e00\u4e2a\u7ebf\u7a0b\uff0c\u5bfc\u81f4timeOne\u6240\u9700\u7684\u65f6\u95f4\u8d85\u8fc7\u4e86\u95f4\u9694\u65f6\u95f4\uff0c\u7ed3\u679c\uff1a<\/p>\n<p>timerOne invoked ,the time:1000timerOne invoked ,the time:5000<\/p>\n<p>2\u3001Timer\u629b\u51fa\u5f02\u5e38\u7f3a\u9677<\/p>\n<p>\u5982\u679cTimerTask\u629b\u51faRuntimeException\uff0cTimer\u4f1a\u7ec8\u6b62\u6240\u6709\u4efb\u52a1\u7684\u8fd0\u884c\u3002\u5982\u4e0b\uff1a<\/p>\n<blockquote><p>public class TimerTest04 {<\/p>\n<p>private Timer timer;<\/p>\n<p>public TimerTest04(){<\/p>\n<p>this.timer = new Timer();<\/p>\n<p>}<\/p>\n<p>public void timerOne(){<\/p>\n<p>timer.schedule(new TimerTask() {<\/p>\n<p>public void run() {<\/p>\n<p>throw new RuntimeException();<\/p>\n<p>}<\/p>\n<p>}, 1000);<\/p>\n<p>}<\/p>\n<p>public void timerTwo(){<\/p>\n<p>timer.schedule(new TimerTask() {<\/p>\n<p>public void run() {<\/p>\n<p>System.out.println(&#8220;\u6211\u4f1a\u4e0d\u4f1a\u6267\u884c\u5462\uff1f\uff1f&#8221;);<\/p>\n<p>}<\/p>\n<p>}, 1000);<\/p>\n<p>}<\/p>\n<p>public static void main(String[] args) {<\/p>\n<p>TimerTest04 test = new TimerTest04();<\/p>\n<p>test.timerOne();<\/p>\n<p>test.timerTwo();<\/p>\n<p>}<\/p>\n<p>}<\/p><\/blockquote>\n<p>\u8fd0\u884c\u7ed3\u679c\uff1atimerOne\u629b\u51fa\u5f02\u5e38\uff0c\u5bfc\u81f4timerTwo\u4efb\u52a1\u7ec8\u6b62\u3002<\/p>\n<blockquote><p>Exception in thread &#8220;Timer-0&#8221; java.lang.RuntimeException \u00a0 \u00a0at com.chenssy.timer.TimerTest04$1.run(TimerTest04.java:25) \u00a0 \u00a0at java.util.TimerThread.mainLoop(Timer.java:555) \u00a0 \u00a0at java.util.TimerThread.run(Timer.java:505)<\/p><\/blockquote>\n<p>\u5bf9\u4e8eTimer\u7684\u7f3a\u9677\uff0c\u6211\u4eec\u53ef\u4ee5\u8003\u8651 ScheduledThreadPoolExecutor \u6765\u66ff\u4ee3\u3002Timer\u662f\u57fa\u4e8e\u7edd\u5bf9\u65f6\u95f4\u7684\uff0c\u5bf9\u7cfb\u7edf\u65f6\u95f4\u6bd4\u8f83\u654f\u611f\uff0c\u800cScheduledThreadPoolExecutor \u5219\u662f\u57fa\u4e8e\u76f8\u5bf9\u65f6\u95f4\uff1bTimer\u662f\u5185\u90e8\u662f\u5355\u4e00\u7ebf\u7a0b\uff0c\u800cScheduledThreadPoolExecutor\u5185\u90e8\u662f\u4e2a\u7ebf\u7a0b\u6c60\uff0c\u6240\u4ee5\u53ef\u4ee5\u652f\u6301\u591a\u4e2a\u4efb\u52a1\u5e76\u53d1\u6267\u884c\u3002<\/p>\n<p><strong>3.2\u3001\u7528ScheduledExecutorService\u66ff\u4ee3Timer<\/strong><\/p>\n<p>1\u3001\u89e3\u51b3\u95ee\u9898\u4e00\uff1a<\/p>\n<blockquote><p>public class ScheduledExecutorTest {<\/p>\n<p>private \u00a0ScheduledExecutorService scheduExec;<\/p>\n<p>public long start;<\/p>\n<p>ScheduledExecutorTest(){<\/p>\n<p>this.scheduExec = \u00a0Executors.newScheduledThreadPool(2);<\/p>\n<p>this.start = System.currentTimeMillis();<\/p>\n<p>}<\/p>\n<p>public void timerOne(){<\/p>\n<p>scheduExec.schedule(new Runnable() {<\/p>\n<p>public void run() {<\/p>\n<p>System.out.println(&#8220;timerOne,the time:&#8221; + (System.currentTimeMillis() &#8211; start));<\/p>\n<p>try {<\/p>\n<p>Thread.sleep(4000);<\/p>\n<p>}<\/p>\n<p>catch (InterruptedException e) {<\/p>\n<p>e.printStackTrace();<\/p>\n<p>}<\/p>\n<p>}<\/p>\n<p>},1000,TimeUnit.MILLISECONDS);<\/p>\n<p>}<\/p>\n<p>public void timerTwo(){<\/p>\n<p>scheduExec.schedule(new Runnable() {<\/p>\n<p>public void run() {<\/p>\n<p>System.out.println(&#8220;timerTwo,the time:&#8221; + (System.currentTimeMillis() &#8211; start));<\/p>\n<p>}<\/p>\n<p>},2000,TimeUnit.MILLISECONDS);<\/p>\n<p>}<\/p>\n<p>public static void main(String[] args) {<\/p>\n<p>ScheduledExecutorTest test = new ScheduledExecutorTest();<\/p>\n<p>test.timerOne();<\/p>\n<p>test.timerTwo();<\/p>\n<p>}<\/p>\n<p>}<\/p><\/blockquote>\n<p>\u8fd0\u884c\u7ed3\u679c\uff1a<\/p>\n<p>timerOne,the time:1003timerTwo,the time:2005<\/p>\n<p>2\u3001\u89e3\u51b3\u95ee\u9898\u4e8c<\/p>\n<blockquote><p>public class ScheduledExecutorTest {<\/p>\n<p>private \u00a0ScheduledExecutorService scheduExec;<\/p>\n<p>public long start;<\/p>\n<p>ScheduledExecutorTest(){<\/p>\n<p>this.scheduExec = \u00a0Executors.newScheduledThreadPool(2);<\/p>\n<p>this.start = System.currentTimeMillis();<\/p>\n<p>}<\/p>\n<p>public void timerOne(){<\/p>\n<p>scheduExec.schedule(new Runnable() {<\/p>\n<p>public void run() {<\/p>\n<p>throw new RuntimeException();<\/p>\n<p>}<\/p>\n<p>},1000,TimeUnit.MILLISECONDS);<\/p>\n<p>}<\/p>\n<p>public void timerTwo(){<\/p>\n<p>scheduExec.scheduleAtFixedRate(new Runnable() {<\/p>\n<p>public void run() {<\/p>\n<p>System.out.println(&#8220;timerTwo invoked &#8230;..&#8221;);<\/p>\n<p>}<\/p>\n<p>},2000,500,TimeUnit.MILLISECONDS);<\/p>\n<p>}<\/p>\n<p>public static void main(String[] args) {<\/p>\n<p>ScheduledExecutorTest test = new ScheduledExecutorTest();<\/p>\n<p>test.timerOne();<\/p>\n<p>test.timerTwo();<\/p>\n<p>}<\/p>\n<p>}<\/p><\/blockquote>\n<p>\u8fd0\u884c\u7ed3\u679c\uff1a<\/p>\n<blockquote><p>timerTwo invoked &#8230;..timerTwo invoked &#8230;..timerTwo invoked &#8230;..timerTwo invoked<\/p><\/blockquote>\n<blockquote><p><strong>\u4f5c\u8005\uff1a chenssy\u00a0<\/strong><\/p>\n<p><strong>\u51fa\u5904\uff1a http:\/\/www.cnblogs.com\/chenssy\/\u00a0<\/strong><\/p>\n<p><strong>\u672c\u6587\u7248\u6743\u5f52\u4f5c\u8005\u548c\u535a\u5ba2\u56ed\u5171\u6709\uff0c\u6b22\u8fce\u8f6c\u8f7d\uff0c\u4f46\u672a\u7ecf\u4f5c\u8005\u540c\u610f\u5fc5\u987b\u4fdd\u7559\u6b64\u6bb5\u58f0\u660e\uff0c\u4e14\u5728\u6587\u7ae0\u9875\u9762\u660e\u663e\u4f4d\u7f6e\u7ed9\u51fa\u539f\u6587\u8fde\u63a5\uff0c\u5426\u5219\u4fdd\u7559\u8ffd\u7a76\u6cd5\u5f8b\u8d23\u4efb\u7684\u6743\u5229\u3002<\/strong><\/p><\/blockquote>\n","protected":false},"excerpt":{"rendered":"<p>\u6765\u81ea\uff1a\u535a\u5ba2\u56ed \u4f5c\u8005\uff1a chenssy\u00a0 \u94fe\u63a5\uff1a\u00a0http:\/\/www.cnblogs.com\/chenssy\/ &hellip; <a href=\"http:\/\/blog.softwareclues.com\/zh\/%e8%af%a6%e8%a7%a3java%e5%ae%9a%e6%97%b6%e4%bb%bb%e5%8a%a1-2\" class=\"more-link\">\u7ee7\u7eed\u9605\u8bfb<span class=\"screen-reader-text\">\u201c\u8be6\u89e3Java\u5b9a\u65f6\u4efb\u52a1\u201d<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","enabled":false}}},"categories":[3],"tags":[8,122],"translation":{"provider":"WPGlobus","version":"2.12.2","language":"zh","enabled_languages":["en","zh"],"languages":{"en":{"title":true,"content":true,"excerpt":false},"zh":{"title":false,"content":false,"excerpt":false}}},"jetpack_publicize_connections":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v22.7 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>\u8be6\u89e3Java\u5b9a\u65f6\u4efb\u52a1 - \u8f6f\u4ef6\u542f\u793a\u5f55<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"http:\/\/blog.softwareclues.com\/\u8be6\u89e3java\u5b9a\u65f6\u4efb\u52a1-2\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"\u8be6\u89e3Java\u5b9a\u65f6\u4efb\u52a1 - \u8f6f\u4ef6\u542f\u793a\u5f55\" \/>\n<meta property=\"og:url\" content=\"http:\/\/blog.softwareclues.com\/\u8be6\u89e3java\u5b9a\u65f6\u4efb\u52a1-2\" \/>\n<meta property=\"og:site_name\" content=\"\u8f6f\u4ef6\u542f\u793a\u5f55\" \/>\n<meta property=\"article:published_time\" content=\"2016-05-21T19:22:22+00:00\" \/>\n<meta name=\"author\" content=\"Editorial Team\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"Editorial Team\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4\" \/>\n\t<meta name=\"twitter:data2\" content=\"4 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"http:\/\/blog.softwareclues.com\/%e8%af%a6%e8%a7%a3java%e5%ae%9a%e6%97%b6%e4%bb%bb%e5%8a%a1-2\",\"url\":\"http:\/\/blog.softwareclues.com\/%e8%af%a6%e8%a7%a3java%e5%ae%9a%e6%97%b6%e4%bb%bb%e5%8a%a1-2\",\"name\":\"\u8be6\u89e3Java\u5b9a\u65f6\u4efb\u52a1 - \u8f6f\u4ef6\u542f\u793a\u5f55\",\"isPartOf\":{\"@id\":\"http:\/\/blog.softwareclues.com\/#website\"},\"datePublished\":\"2016-05-21T19:22:22+00:00\",\"dateModified\":\"2016-05-21T19:22:22+00:00\",\"author\":{\"@id\":\"http:\/\/blog.softwareclues.com\/#\/schema\/person\/4c47e4e97a658930b6c0e90f4a4eda82\"},\"breadcrumb\":{\"@id\":\"http:\/\/blog.softwareclues.com\/%e8%af%a6%e8%a7%a3java%e5%ae%9a%e6%97%b6%e4%bb%bb%e5%8a%a1-2#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"http:\/\/blog.softwareclues.com\/%e8%af%a6%e8%a7%a3java%e5%ae%9a%e6%97%b6%e4%bb%bb%e5%8a%a1-2\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"http:\/\/blog.softwareclues.com\/%e8%af%a6%e8%a7%a3java%e5%ae%9a%e6%97%b6%e4%bb%bb%e5%8a%a1-2#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"http:\/\/blog.softwareclues.com\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"\u8be6\u89e3Java\u5b9a\u65f6\u4efb\u52a1\"}]},{\"@type\":\"WebSite\",\"@id\":\"http:\/\/blog.softwareclues.com\/#website\",\"url\":\"http:\/\/blog.softwareclues.com\/\",\"name\":\"\u8f6f\u4ef6\u542f\u793a\u5f55\",\"description\":\"\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"http:\/\/blog.softwareclues.com\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"zh-Hans\"},{\"@type\":\"Person\",\"@id\":\"http:\/\/blog.softwareclues.com\/#\/schema\/person\/4c47e4e97a658930b6c0e90f4a4eda82\",\"name\":\"Editorial Team\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"http:\/\/blog.softwareclues.com\/#\/schema\/person\/image\/\",\"url\":\"http:\/\/2.gravatar.com\/avatar\/e4fb391d9f5bb29583ed9579324a5e17?s=96&d=mystery&r=g\",\"contentUrl\":\"http:\/\/2.gravatar.com\/avatar\/e4fb391d9f5bb29583ed9579324a5e17?s=96&d=mystery&r=g\",\"caption\":\"Editorial Team\"},\"url\":\"http:\/\/blog.softwareclues.com\/zh\/author\/admin\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"\u8be6\u89e3Java\u5b9a\u65f6\u4efb\u52a1 - \u8f6f\u4ef6\u542f\u793a\u5f55","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"http:\/\/blog.softwareclues.com\/\u8be6\u89e3java\u5b9a\u65f6\u4efb\u52a1-2","og_locale":"zh_CN","og_type":"article","og_title":"\u8be6\u89e3Java\u5b9a\u65f6\u4efb\u52a1 - \u8f6f\u4ef6\u542f\u793a\u5f55","og_url":"http:\/\/blog.softwareclues.com\/\u8be6\u89e3java\u5b9a\u65f6\u4efb\u52a1-2","og_site_name":"\u8f6f\u4ef6\u542f\u793a\u5f55","article_published_time":"2016-05-21T19:22:22+00:00","author":"Editorial Team","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"Editorial Team","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"4 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"http:\/\/blog.softwareclues.com\/%e8%af%a6%e8%a7%a3java%e5%ae%9a%e6%97%b6%e4%bb%bb%e5%8a%a1-2","url":"http:\/\/blog.softwareclues.com\/%e8%af%a6%e8%a7%a3java%e5%ae%9a%e6%97%b6%e4%bb%bb%e5%8a%a1-2","name":"\u8be6\u89e3Java\u5b9a\u65f6\u4efb\u52a1 - \u8f6f\u4ef6\u542f\u793a\u5f55","isPartOf":{"@id":"http:\/\/blog.softwareclues.com\/#website"},"datePublished":"2016-05-21T19:22:22+00:00","dateModified":"2016-05-21T19:22:22+00:00","author":{"@id":"http:\/\/blog.softwareclues.com\/#\/schema\/person\/4c47e4e97a658930b6c0e90f4a4eda82"},"breadcrumb":{"@id":"http:\/\/blog.softwareclues.com\/%e8%af%a6%e8%a7%a3java%e5%ae%9a%e6%97%b6%e4%bb%bb%e5%8a%a1-2#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["http:\/\/blog.softwareclues.com\/%e8%af%a6%e8%a7%a3java%e5%ae%9a%e6%97%b6%e4%bb%bb%e5%8a%a1-2"]}]},{"@type":"BreadcrumbList","@id":"http:\/\/blog.softwareclues.com\/%e8%af%a6%e8%a7%a3java%e5%ae%9a%e6%97%b6%e4%bb%bb%e5%8a%a1-2#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"http:\/\/blog.softwareclues.com\/"},{"@type":"ListItem","position":2,"name":"\u8be6\u89e3Java\u5b9a\u65f6\u4efb\u52a1"}]},{"@type":"WebSite","@id":"http:\/\/blog.softwareclues.com\/#website","url":"http:\/\/blog.softwareclues.com\/","name":"\u8f6f\u4ef6\u542f\u793a\u5f55","description":"","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"http:\/\/blog.softwareclues.com\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"zh-Hans"},{"@type":"Person","@id":"http:\/\/blog.softwareclues.com\/#\/schema\/person\/4c47e4e97a658930b6c0e90f4a4eda82","name":"Editorial Team","image":{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"http:\/\/blog.softwareclues.com\/#\/schema\/person\/image\/","url":"http:\/\/2.gravatar.com\/avatar\/e4fb391d9f5bb29583ed9579324a5e17?s=96&d=mystery&r=g","contentUrl":"http:\/\/2.gravatar.com\/avatar\/e4fb391d9f5bb29583ed9579324a5e17?s=96&d=mystery&r=g","caption":"Editorial Team"},"url":"http:\/\/blog.softwareclues.com\/zh\/author\/admin"}]}},"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/paLJfj-aS","jetpack-related-posts":[],"_links":{"self":[{"href":"http:\/\/blog.softwareclues.com\/zh\/wp-json\/wp\/v2\/posts\/674"}],"collection":[{"href":"http:\/\/blog.softwareclues.com\/zh\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/blog.softwareclues.com\/zh\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/blog.softwareclues.com\/zh\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"http:\/\/blog.softwareclues.com\/zh\/wp-json\/wp\/v2\/comments?post=674"}],"version-history":[{"count":2,"href":"http:\/\/blog.softwareclues.com\/zh\/wp-json\/wp\/v2\/posts\/674\/revisions"}],"predecessor-version":[{"id":676,"href":"http:\/\/blog.softwareclues.com\/zh\/wp-json\/wp\/v2\/posts\/674\/revisions\/676"}],"wp:attachment":[{"href":"http:\/\/blog.softwareclues.com\/zh\/wp-json\/wp\/v2\/media?parent=674"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/blog.softwareclues.com\/zh\/wp-json\/wp\/v2\/categories?post=674"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/blog.softwareclues.com\/zh\/wp-json\/wp\/v2\/tags?post=674"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}