826220679@qq.com
2025-10-31 9aca70f16836952e2e3462ecc69dabe679811eb7
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
package Ymodem;
 
class Timer {
 
    private long startTime = 0;
    private long stopTime = 0;
    private long timeout = 0;
 
    public Timer(long timeout) {
        this.timeout = timeout;
    }
 
    public Timer start() {
        this.startTime = System.currentTimeMillis();
        this.stopTime = 0;
        return this;
    }
 
    public void stop() {
        this.stopTime = System.currentTimeMillis();
    }
 
    public boolean isExpired() {
        return (System.currentTimeMillis() > startTime + timeout);
    }
 
    public long getStartTime() {
        return this.startTime;
    }
 
    public long getStopTime() {
        return this.stopTime;
    }
 
    public long getTotalTime() {
        return this.stopTime - this.startTime;
    }
 
    public long getTimeout() {
        return timeout;
    }
 
    public void setTimeout(long timeout) {
        this.timeout = timeout;
    }
 
    public boolean isWorking() {
        return (stopTime != 0);
    }
}