💎一站式轻松地调用各大LLM模型接口,支持GPT4、智谱、星火、月之暗面及文生图 广告
#### 同步代码块 ``` synchronized(同步锁){       需要同步操作的代码 } ``` ``` public static class Ticker implements Runnable{ private int total = 100; // 同步锁 Object lock = new Object(); @Override public void run() { synchronized (lock){ //同步锁 while (true){ if (total > 0){ try { Thread.sleep(100); } catch (InterruptedException e) { e.printStackTrace(); } System.out.println("tick total is = " + total--); } } } } } ```