Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TSBM - queue.take blocking #5

Open
ylin30 opened this issue Nov 5, 2021 · 1 comment
Open

TSBM - queue.take blocking #5

ylin30 opened this issue Nov 5, 2021 · 1 comment
Assignees

Comments

@ylin30
Copy link

ylin30 commented Nov 5, 2021

queue.take() will hang forever and block thread2.join and thread3.join later. You can use queue.poll(timeout, unit) instead.

@@ -255,9 +258,9 @@ public class TSBM {
break;
}
try {

  •                    String data = queue.take();
    
  •                    String data = queue.poll(100, TimeUnit.MILLISECONDS);
                       if (data == null) {
    
  •                        Thread.sleep(100);
    
  •                        //Thread.sleep(100);
                           continue;
                       }
                       adapter.insertData(data);
    

@@ -265,6 +268,7 @@ public class TSBM {
e.printStackTrace();
}

image

@rainmaple
Copy link
Collaborator

Thanks, you can fork this, then make a PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants