File tree Expand file tree Collapse file tree 1 file changed +5
-4
lines changed
driver-sync/src/examples/documentation Expand file tree Collapse file tree 1 file changed +5
-4
lines changed Original file line number Diff line number Diff line change @@ -702,13 +702,13 @@ public void testDeletions() {
702
702
}
703
703
704
704
@ Test
705
- public void testWatch () {
705
+ public void testWatch () throws InterruptedException {
706
706
assumeTrue (isDiscoverableReplicaSet () && serverVersionAtLeast (3 , 6 ));
707
707
708
708
final MongoCollection <Document > inventory = collection ;
709
709
final AtomicBoolean stop = new AtomicBoolean (false );
710
710
711
- new Thread (new Runnable () {
711
+ Thread thread = new Thread (new Runnable () {
712
712
@ Override
713
713
public void run () {
714
714
while (!stop .get ()) {
@@ -721,8 +721,8 @@ public void run() {
721
721
collection .deleteOne (new Document ("username" , "alice" ));
722
722
}
723
723
}
724
- }). start () ;
725
-
724
+ });
725
+ thread . start ();
726
726
727
727
// Start Changestream Example 1
728
728
MongoCursor <ChangeStreamDocument <Document >> cursor = inventory .watch ().iterator ();
@@ -756,6 +756,7 @@ public void run() {
756
756
cursor .close ();
757
757
758
758
stop .set (true );
759
+ thread .join ();
759
760
}
760
761
761
762
@ Test
You can’t perform that action at this time.
0 commit comments