@Override
        public String command(String id, int timeout, String params) throws RemoteException {
            CommandExecutor executor = mCommandExecutorMap.get(id);
            if (executor == null) {
                synchronized (mCommandExecutorMap) {
                    executor = mCommandExecutorMap.get(id);
                    if (executor == null) {
                        executor = CommandExecutor.create(timeout, params);
                        if (executor != null) {
                            mCommandExecutorMap.put(id, executor);
                        }
                    }
                }
            }

            // Get Result
            String result = executor != null ? executor.getResult() : null;

            synchronized (mCommandExecutorMap) {
                try {
                    mCommandExecutorMap.remove(id);
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }

            return result;
        }
Run Command

@param params params
@return result
@throws RemoteException
caprice/kit-cmd/src/main/java/net/qiujuer/genius/kit/cmd/CommandService.java