Java Code Examples for java.util.stream.Stream#sequential()

The following examples show how to use java.util.stream.Stream#sequential() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: StreamParSeqTest.java    From dragonwell8_jdk with GNU General Public License v2.0 6 votes vote down vote up
public void testParSeq() {
    Stream<Integer> s = Arrays.asList(1, 2, 3, 4).stream().parallel();
    assertTrue(s.isParallel());

    s = s.sequential();
    assertFalse(s.isParallel());

    s = s.sequential();
    assertFalse(s.isParallel());

    s = s.parallel();
    assertTrue(s.isParallel());

    s = s.parallel();
    assertTrue(s.isParallel());
}
 
Example 2
Source File: StreamParSeqTest.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
public void testParSeq() {
    Stream<Integer> s = Arrays.asList(1, 2, 3, 4).stream().parallel();
    assertTrue(s.isParallel());

    s = s.sequential();
    assertFalse(s.isParallel());

    s = s.sequential();
    assertFalse(s.isParallel());

    s = s.parallel();
    assertTrue(s.isParallel());

    s = s.parallel();
    assertTrue(s.isParallel());
}
 
Example 3
Source File: StreamParSeqTest.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
public void testParSeq() {
    Stream<Integer> s = Arrays.asList(1, 2, 3, 4).stream().parallel();
    assertTrue(s.isParallel());

    s = s.sequential();
    assertFalse(s.isParallel());

    s = s.sequential();
    assertFalse(s.isParallel());

    s = s.parallel();
    assertTrue(s.isParallel());

    s = s.parallel();
    assertTrue(s.isParallel());
}
 
Example 4
Source File: StreamParSeqTest.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
public void testParSeq() {
    Stream<Integer> s = Arrays.asList(1, 2, 3, 4).stream().parallel();
    assertTrue(s.isParallel());

    s = s.sequential();
    assertFalse(s.isParallel());

    s = s.sequential();
    assertFalse(s.isParallel());

    s = s.parallel();
    assertTrue(s.isParallel());

    s = s.parallel();
    assertTrue(s.isParallel());
}
 
Example 5
Source File: StreamParSeqTest.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
public void testParSeq() {
    Stream<Integer> s = Arrays.asList(1, 2, 3, 4).stream().parallel();
    assertTrue(s.isParallel());

    s = s.sequential();
    assertFalse(s.isParallel());

    s = s.sequential();
    assertFalse(s.isParallel());

    s = s.parallel();
    assertTrue(s.isParallel());

    s = s.parallel();
    assertTrue(s.isParallel());
}
 
Example 6
Source File: StreamParSeqTest.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
public void testParSeq() {
    Stream<Integer> s = Arrays.asList(1, 2, 3, 4).stream().parallel();
    assertTrue(s.isParallel());

    s = s.sequential();
    assertFalse(s.isParallel());

    s = s.sequential();
    assertFalse(s.isParallel());

    s = s.parallel();
    assertTrue(s.isParallel());

    s = s.parallel();
    assertTrue(s.isParallel());
}
 
Example 7
Source File: StreamParSeqTest.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
public void testParSeq() {
    Stream<Integer> s = Arrays.asList(1, 2, 3, 4).stream().parallel();
    assertTrue(s.isParallel());

    s = s.sequential();
    assertFalse(s.isParallel());

    s = s.sequential();
    assertFalse(s.isParallel());

    s = s.parallel();
    assertTrue(s.isParallel());

    s = s.parallel();
    assertTrue(s.isParallel());
}
 
Example 8
Source File: StreamParSeqTest.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
public void testParSeq() {
    Stream<Integer> s = Arrays.asList(1, 2, 3, 4).stream().parallel();
    assertTrue(s.isParallel());

    s = s.sequential();
    assertFalse(s.isParallel());

    s = s.sequential();
    assertFalse(s.isParallel());

    s = s.parallel();
    assertTrue(s.isParallel());

    s = s.parallel();
    assertTrue(s.isParallel());
}
 
Example 9
Source File: StreamParSeqTest.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
public void testParSeq() {
    Stream<Integer> s = Arrays.asList(1, 2, 3, 4).stream().parallel();
    assertTrue(s.isParallel());

    s = s.sequential();
    assertFalse(s.isParallel());

    s = s.sequential();
    assertFalse(s.isParallel());

    s = s.parallel();
    assertTrue(s.isParallel());

    s = s.parallel();
    assertTrue(s.isParallel());
}
 
Example 10
Source File: StreamParSeqTest.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
public void testParSeq() {
    Stream<Integer> s = Arrays.asList(1, 2, 3, 4).stream().parallel();
    assertTrue(s.isParallel());

    s = s.sequential();
    assertFalse(s.isParallel());

    s = s.sequential();
    assertFalse(s.isParallel());

    s = s.parallel();
    assertTrue(s.isParallel());

    s = s.parallel();
    assertTrue(s.isParallel());
}
 
Example 11
Source File: StreamParSeqTest.java    From jdk8u_jdk with GNU General Public License v2.0 6 votes vote down vote up
public void testParSeq() {
    Stream<Integer> s = Arrays.asList(1, 2, 3, 4).stream().parallel();
    assertTrue(s.isParallel());

    s = s.sequential();
    assertFalse(s.isParallel());

    s = s.sequential();
    assertFalse(s.isParallel());

    s = s.parallel();
    assertTrue(s.isParallel());

    s = s.parallel();
    assertTrue(s.isParallel());
}
 
Example 12
Source File: TestHelpers.java    From streamex with Apache License 2.0 6 votes vote down vote up
public Stream<T> get() {
    Stream<T> res = base.get();
    switch (mode) {
    case NORMAL:
    case SPLITERATOR: 
        return res.sequential();
    case PARALLEL:
        return res.parallel();
    case APPEND:
        // using Stream.empty() or Arrays.asList() here is optimized out
        // in append/prepend which is undesired
        return StreamEx.of(res.parallel()).append(new ConcurrentLinkedQueue<>());
    case PREPEND:
        return StreamEx.of(res.parallel()).prepend(new ConcurrentLinkedQueue<>());
    case RANDOM:
        return StreamEx.of(new EmptyingSpliterator<>(res.parallel().spliterator())).parallel();
    default:
        throw new InternalError("Unsupported mode: " + mode);
    }
}
 
Example 13
Source File: StreamParSeqTest.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
public void testParSeq() {
    Stream<Integer> s = Arrays.asList(1, 2, 3, 4).stream().parallel();
    assertTrue(s.isParallel());

    s = s.sequential();
    assertFalse(s.isParallel());

    s = s.sequential();
    assertFalse(s.isParallel());

    s = s.parallel();
    assertTrue(s.isParallel());

    s = s.parallel();
    assertTrue(s.isParallel());
}
 
Example 14
Source File: StreamParSeqTest.java    From jdk8u-dev-jdk with GNU General Public License v2.0 6 votes vote down vote up
public void testParSeq() {
    Stream<Integer> s = Arrays.asList(1, 2, 3, 4).stream().parallel();
    assertTrue(s.isParallel());

    s = s.sequential();
    assertFalse(s.isParallel());

    s = s.sequential();
    assertFalse(s.isParallel());

    s = s.parallel();
    assertTrue(s.isParallel());

    s = s.parallel();
    assertTrue(s.isParallel());
}