Skip to content

Wait() causes main thread to block #14

Description

@shoerob

When calling any of the public connect() methods from an Activity, these all route to the core connect() method that spawns a SocketThread.

Code like this executes a few times while the connection is being established. If you call connect() from the main thread, and plan on doing subsequent UI updates, this can be problematic.

        synchronized (mSocketThread) {
            try {
                mSocketThread.wait();
            } catch (InterruptedException e) {
            }
        }

This causes the main thread to block for long periods in certain situations, such as a connection taking a long time to establish. This is not ideal in situations where the UI needs to show a status of the connection. With a little refactoring, I think these waits can probably be removed to fix this.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions