aboutsummaryrefslogtreecommitdiff
path: root/0.20.0/tests/threads_detach.rs
blob: 922bca7081c59386673026bde5c1aa349b31a164 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#![cfg(feature = "invocation")]

use std::thread::spawn;

mod util;
use util::{attach_current_thread_permanently, call_java_abs, jvm};

#[test]
fn thread_detaches_when_finished() {
    let thread = spawn(|| {
        let env = attach_current_thread_permanently();
        let val = call_java_abs(&env, -2);
        assert_eq!(val, 2);
        assert_eq!(jvm().threads_attached(), 1);
    });

    thread.join().unwrap();
    assert_eq!(jvm().threads_attached(), 0);
}