macOS内存盘备份老大难问题
内容接上一篇创建内存盘的文章。
在有了开机自动创建内存盘的(基础)功能之后,
果果屡次遭遇了注销、重启导致还在内存盘中的文件丢失。
虽然大部分是说重要也不重要,说不重要也懒得再费流量的下载文件,没有来得及转移和消费它们,
而且放置在内存盘中的文件应该有朝生夕灭的觉悟,重要的不可再生的文件不应该放置于此。
这回我们就来探究一下如何在macOS下自动备份内存盘,并在创建时恢复之前状态。
当想要让当前进程暂时歇个几百毫秒,肯定见过 Thread.sleep(long) 方法。在各种模拟线程长时间工作的代码中时常见到。不过我看到他们有好几个变体
public class Thread implements Runnable {
public static native Thread currentThread();
public static native void sleep(long millis) throws InterruptedException;
public static void sleep(long millis, int nanos) throws InterruptedException;
}
public enum java.util.concurrent.TimeUnit {
public void sleep(long timeout) throws InterruptedException;
}
// 让当前线程休眠3秒
TimeUnit.SECONDS.sleep(3);
Thread.currentThread().sleep(3000);
Thread.sleep(3000);