using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace OneNote2PDF { /// /// 全局 app 对象 /// class App { public string inputDir = ""; public string outputDir = ""; private static App app; private static readonly object locker = new object(); // 对象锁标志 public static App getInstance() { if (app == null) { lock (locker) //标志对象加锁,多线程内部代码会挂起 { if (app == null) { app = new App(); } } } return app; } } }