다 중 스 레 드 사용
package cm.aichijihua;
public class ThreadTest1 {
public static void main(String[] args) {
// 1 run() run
Thread thread = new Thread(){
@Override
public void run() {
while (true) {
try {
Thread.sleep(500);
} catch (InterruptedException e) {
e.printStackTrace();
}
System.out.println(Thread.currentThread().getName());
System.out.println(this.getName());
}
}
};
thread.start();
// 2 , Runable run
// , run Runable
Thread thread2 = new Thread(new Runnable() {
@Override
public void run() {
while (true) {
try {
Thread.sleep(500);
} catch (InterruptedException e) {
e.printStackTrace();
}
System.out.println(Thread.currentThread().getName());
}
}
});
thread2.start();
// , , , Runable run
new Thread(new Runnable() {
@Override
public void run() {
while (true) {
try {
Thread.sleep(500);
} catch (InterruptedException e) {
e.printStackTrace();
}
System.out.println(" ");
}
}
}){
public void run() {
while (true) {
try {
Thread.sleep(500);
} catch (InterruptedException e) {
e.printStackTrace();
}
System.out.println(" ");
}
};
}.start();
}
}
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
링크 ux 다 중 스 레 드 웹 페이지 캡 처 - shell테스트 를 통 해 cuty capt 캡 처 는 느 리 지만 안정 적 이 고 phantomjs 캡 처 속도 가 빠 르 지만 프로 세 스 가 가사 하 는 경우 가 있다.이해득실 을 따 져 보고 cutycapt + 셸 스...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.