SyndContentImpl.value=
public class ThreadTest1
{
private int j;
public static void main(String args[])
{
ThreadTest1 tt=new ThreadTest1();
Inc inc=tt.new Inc();
Dec dec=tt.new Dec();
for(int i=0;i<2;i++)
{
Thread t= new Thread(inc);
t.start();
t=new Thread(dec);
t.start();
}
}
private synchronized void inc()
{
j++;
System.out.println(Thread.currentThread.getName()+”-inc:”+j);
}
private synchronized void dec()
{
j–;
System.out.println(Thread.currentThread.getName()+”-dec”+j);
}
class Inc implements Runnable{
public void run()
{
for(int i=0;i<100;i++)
{
inc();
}
}
}
Class Dec implements Runnable{
public void run()
{
for(int i=0;i<100;i++)
{
dec();
}
}
}
}
作者: 平安夜 发表于 2012-01-26 01:12 原文链接
最新新闻:
· Gmail logo 背后的故事(2012-01-26 23:22)
· 得益于Kindle Fire的火爆,Android平板市场份额飙升至39%(2012-01-26 23:21)
· 二月十四情人节愤怒的小鸟登陆Facebook(2012-01-26 22:55)
· 程苓峰:新浪越成功,就离互联网越远。(2012-01-26 22:29)
· Ubuntu将用搜索界面HUD取代菜单(2012-01-26 21:34)
编辑推荐:我是如何学习计算机编程的
SyndContentImpl.interface=interface com.sun.syndication.feed.synd.SyndContent
SyndContentImpl.type=text/plain