提高程序的稳定性

This commit is contained in:
Administrator
2023-03-09 08:26:54 +08:00
parent f2b6394688
commit 2d6122480a
14 changed files with 298 additions and 133 deletions
@@ -7,8 +7,8 @@ import java.util.concurrent.atomic.AtomicLong;
public class OutputMetre extends OutputStream {
private OutputStream out;
private AtomicLong total;
public OutputMetre(OutputStream outputStream,AtomicLong v) {
private AtomicLong[] total;
public OutputMetre(OutputStream outputStream,AtomicLong ...v) {
this.out=outputStream;
this.total=v;
}
@@ -16,19 +16,22 @@ public class OutputMetre extends OutputStream {
@Override
public void write(int b) throws IOException {
out.write(b);
total.incrementAndGet();
for(AtomicLong x:total)
x.incrementAndGet();
}
@Override
public void write(byte[] b) throws IOException {
out.write(b);
total.addAndGet(b.length);
for(AtomicLong x:total)
x.addAndGet(b.length);
}
@Override
public void write(byte[] b, int off, int len) throws IOException {
out.write(b, off, len);
total.addAndGet(len);
for(AtomicLong x:total)
x.addAndGet(len);
}
@Override