package com.skcc.mthread;
為潯陽(yáng)等地區(qū)用戶提供了全套網(wǎng)頁(yè)設(shè)計(jì)制作服務(wù),及潯陽(yáng)網(wǎng)站建設(shè)行業(yè)解決方案。主營(yíng)業(yè)務(wù)為網(wǎng)站設(shè)計(jì)、成都網(wǎng)站制作、潯陽(yáng)網(wǎng)站設(shè)計(jì),以傳統(tǒng)方式定制建設(shè)網(wǎng)站,并提供域名空間備案等一條龍服務(wù),秉承以專業(yè)、用心的態(tài)度為用戶提供真誠(chéng)的服務(wù)。我們深信只要達(dá)到每一位用戶的要求,就會(huì)得到認(rèn)可,從而選擇與我們長(zhǎng)期合作。這樣,我們也可以走得更遠(yuǎn)!
public class MyThread001 extends Thread {
private int count=4;
public MyThread001() {
// TODO Auto-generated constructor stub
}
@Override
public synchronized void run() {
count--;
System.out.println(Thread.currentThread().getName() + " = " + count);
}
/***
* 多個(gè)線程同時(shí)競(jìng)爭(zhēng)MyThread001類實(shí)例對(duì)象及成員方法
* 多個(gè)線程按照CPU分配時(shí)間順序來執(zhí)行,(t1到t4的執(zhí)行順序需參考CPU分配的順序來定)
*
* ****/
public static void main(String[] args) {
// TODO Auto-generated method stub
MyThread001 myThread = new MyThread001();
Thread t1 = new Thread(myThread,"t1");
Thread t2 = new Thread(myThread,"t2");
Thread t3 = new Thread(myThread,"t3");
Thread t4 = new Thread(myThread,"t4");
t1.start();
t2.start();
t3.start();
t4.start();
}
}