public static void main(String[] args) throws Exception {
		Globals.lockManager = new LockManager();
		Globals.bufferManager = new BufferManager(Globals.PAGES + 3);
		Globals.index = new BPlus(1); // xactionId whatever you want
		Globals.threads = new HashMap<Long, Thread>();
		Globals.threadResults = new HashMap<Long, StringBuilder>();

		System.out.println("Index on start...");
		Globals.index.debugPrint(1, System.out);
		Globals.lockManager.releaseLocks(1); // Release locks of creation
		Globals.lockManager.allClear(1);

		DeadlockDetector dd = new DeadlockDetector();
		dd.start();

		if (!READFROMFILE) {
			String clientSentence;
			ServerSocket welcomeSocket = new ServerSocket(5678);

			int counter = 0;
			while (true) {
				Socket connectionSocket = welcomeSocket.accept();
				BufferedReader inFromClient = new BufferedReader(
						new InputStreamReader(connectionSocket.getInputStream()));

				clientSentence = inFromClient.readLine();
				System.out.println("**" + (++counter) + "Received: "
						+ clientSentence);
				if (clientSentence.startsWith("END ALL"))
					break;

				Server s = new Server(clientSentence);
				Globals.threads.put(s.getId(), s);
				s.start();
			}

			System.out.println("Waiting threads to terminate...");
			int count = 0;
			for (Entry<Long, Thread> t : Globals.threads.entrySet()) {
				t.getValue().join();
				count++;
				// System.out.println(count);
			}

			welcomeSocket.close();
		} else {
			FileInputStream fis = null;
			BufferedReader reader = null;

			try {
				fis = new FileInputStream(new File("input_del.txt"));
				reader = new BufferedReader(new InputStreamReader(fis));

				System.out
						.println("Reading File line by line using BufferedReader");

				String line = reader.readLine();
				while (line != null) {
					if (line.equals("END ALL"))
						break;
					Server s = new Server(line);
					Globals.threads.put(s.getId(), s);
					s.start();
					line = reader.readLine();
				}

			} catch (Exception ex) {
			} finally {
				try {
					reader.close();
					fis.close();
				} catch (IOException ex) {

				}
			}

			int count = 0;
			for (Entry<Long, Thread> t : Globals.threads.entrySet()) {
				t.getValue().join();
				count++;
			}
		}

		System.out.println("FINISH ");
		Globals.index.debugPrint(1, System.out);
		// Globals.index.rangeQuery(false, 1, System.out);
		Globals.lockManager.releaseLocks(1); // Release locks of creation

		dd.interrupt();
	}