Create Sync.java

use synchronize to control access