本帖最后由 霜林醉zhx 于 2014-7-8 21:54 编辑
- class Sale
- {
- public static void main(String[] args)
- {
- Tickit t = new Tickit();
- Thread t1 = new Thread(t);
- Thread t2 = new Thread(t);
- Thread t3 = new Thread(t);
- Thread t4 = new Thread(t);
- t1.start();
- t2.start();
- t3.start();
- t4.start();
- }
- }
- class Tickit implements Runnable
- {
- private int tick=100;
- public void run()
- {
- while (true)
- {
- if (tick>0)
- {
- System.out.println(Thread.currentThread().getName()+"---"+tick);
- }
- tick--;
- }
- }
- }
复制代码 这是毕老师视频里卖票那个例子的原码。我在练习的时候,将class tickit中的private int tick=100; 分行写成了:private int tick;
tick=100;
编译时,给我说tick=100; 这一行错误,需要<标识符>。什么意思?
- private int tick;
- tick=100;
复制代码
|
|