Why is synchronized not working?
问题 I am trying to write a method that asks a device for input and then accepts a response, all as an atomic operation. Here is my code (the query method is really what should be focused on): public class DeviceConnection implements Runnable{ //For query static int test = 0; //For writeline static PrintWriter out = null; //(initialized in constructor) //Only important for readline static String[] systemMessage=new String[10]; static int messageIn=0; static int messageOut=0; static boolean