1.javaä¸interrupt
javaä¸interrupt
JDK APIç说æå¦ä¸ï¼
public void interrupt()
ä¸æ线ç¨ã
å¦æå½å线ç¨æ²¡æä¸æå®èªå·±ï¼è¿å¨ä»»ä½æ åµä¸é½æ¯å 许çï¼ï¼å该线ç¨ç checkAccess æ¹æ³å°±ä¼è¢«è°ç¨ï¼è¿å¯è½æåº SecurityExceptionã
å¦æ线ç¨å¨è°ç¨ Object ç±»ç wait()ãwait(long) æ wait(long,源码应用市场 源码 int) æ¹æ³ï¼æè 该类ç join()ãjoin(long)ãjoin(long, int)ãsleep(long) æ sleep(long, int) æ¹æ³è¿ç¨ä¸åé»ï¼åå ¶ä¸æç¶æå°è¢«æ¸ é¤ï¼å®è¿å°æ¶å°ä¸ä¸ª InterruptedExceptionã
å¦æ该线ç¨å¨å¯ä¸æçééä¸ç I/O æä½ä¸åé»ï¼å该ééå°è¢«å ³éï¼è¯¥çº¿ç¨çä¸æç¶æå°è¢«è®¾ç½®å¹¶ä¸è¯¥çº¿ç¨å°æ¶å°ä¸ä¸ª ClosedByInterruptExceptionã
å¦æ该线ç¨å¨ä¸ä¸ª Selector ä¸åé»ï¼å该线ç¨çä¸æç¶æå°è¢«è®¾ç½®ï¼å®å°ç«å³ä»éæ©æä½è¿åï¼å¹¶å¯è½å¸¦æä¸ä¸ªéé¶å¼ï¼å°±å¥½åè°ç¨äºéæ©å¨ç wakeup æ¹æ³ä¸æ ·ã
å¦æ以åçæ¡ä»¶é½æ²¡æä¿åï¼å该线ç¨çä¸æç¶æå°è¢«è®¾ç½®ã
ä¸æä¸ä¸ªä¸å¤äºæ´»å¨ç¶æç线ç¨ä¸éè¦ä»»ä½ä½ç¨ã
æåºï¼
SecurityException - å¦æå½å线ç¨æ æ³ä¿®æ¹è¯¥çº¿ç¨ã
注æè¿å¥ï¼å¦æå½å线ç¨æ²¡æä¸æå®èªå·±ï¼è¿å¨ä»»ä½æ åµä¸é½æ¯å 许çï¼
说æè°ç¨interruptæ¹æ³ä¸ä¸å®ä¼ççä¸æ线ç¨ã