Skip to content

Commit 6fe74b5

Browse files
FridaTveitlemoncurry
authored andcommitted
parallel-letter-frequency: remove failing test (exercism#1766)
The last test for the parallel-letter-frequency exercise is now consistently failing as it runs out of memory. As this exercise is quite complicated as well and could confused users, we've decided to remove it.
1 parent 40da908 commit 6fe74b5

2 files changed

Lines changed: 2 additions & 91 deletions

File tree

exercises/parallel-letter-frequency/README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ list of texts and that employs parallelism.
99

1010
# Tips
1111

12-
Single-threaded (non-concurrent) solutions can pass all tests [but the last.](https://www.youtube.com/watch?v=mJZZNHekEQw) Your solution will be tested for concurrency by submitting it as a [Runnable](https://docs.oracle.com/javase/7/docs/api/java/lang/Runnable.html) to an [ExecutorService.](https://docs.oracle.com/javase/7/docs/api/java/util/concurrent/ExecutorService.html) Your solution must leverage multiple [Threads](https://docs.oracle.com/javase/7/docs/api/java/lang/Thread.html) to pass the final test.
12+
Single-threaded (non-concurrent) solutions can pass all tests but you should try to implement the solution using parallelism.
13+
You can do this by using multiple [Threads](https://docs.oracle.com/javase/7/docs/api/java/lang/Thread.html).
1314

1415
Java documentation on [parallel streams](https://docs.oracle.com/javase/tutorial/collections/streams/parallelism.html) may provide some help.
1516

exercises/parallel-letter-frequency/src/test/java/ParallelLetterFrequencyTest.java

Lines changed: 0 additions & 90 deletions
Original file line numberDiff line numberDiff line change
@@ -108,94 +108,4 @@ public void numbersDontCount() {
108108

109109
assertFalse(p.letterCounts().containsKey((int) '1'));
110110
}
111-
112-
@Ignore("Remove to run test")
113-
@Test
114-
public void multipleThreadsGetUsed()
115-
throws InterruptedException, ExecutionException {
116-
117-
118-
class MyForkJoinWorkerThread extends ForkJoinWorkerThread {
119-
120-
boolean wasStarted = false;
121-
122-
public MyForkJoinWorkerThread(ForkJoinPool pool) {
123-
super(pool);
124-
}
125-
126-
@Override
127-
public void start() {
128-
super.start();
129-
this.wasStarted = true;
130-
}
131-
}
132-
133-
List<MyForkJoinWorkerThread> allThreads = new ArrayList<>();
134-
135-
class MyForkJoinThreadFactory implements ForkJoinPool.ForkJoinWorkerThreadFactory {
136-
public MyForkJoinThreadFactory() {
137-
super();
138-
}
139-
140-
public MyForkJoinWorkerThread newThread(ForkJoinPool pool) {
141-
final MyForkJoinWorkerThread worker = new MyForkJoinWorkerThread(pool);
142-
worker.setName("Thread number: " + worker.getPoolIndex());
143-
allThreads.add(worker);
144-
return worker;
145-
}
146-
}
147-
148-
MyForkJoinThreadFactory factory = new MyForkJoinThreadFactory();
149-
ForkJoinPool multiThreadPool = new ForkJoinPool(4,
150-
(ForkJoinPool.ForkJoinWorkerThreadFactory) factory,
151-
null,
152-
false);
153-
154-
String input = "abcdefghijklmnopqrstuvwxyz";
155-
StringBuilder b = new StringBuilder();
156-
for (int i = 1; i < 10000000; i++) {
157-
b.append(input);
158-
}
159-
160-
Map<Integer, Integer> expectedOutput = new HashMap<Integer, Integer>() {
161-
{
162-
put((int) 'a', 10000000);
163-
put((int) 'b', 10000000);
164-
put((int) 'c', 10000000);
165-
put((int) 'd', 10000000);
166-
put((int) 'e', 10000000);
167-
put((int) 'f', 10000000);
168-
put((int) 'g', 10000000);
169-
put((int) 'h', 10000000);
170-
put((int) 'i', 10000000);
171-
put((int) 'j', 10000000);
172-
put((int) 'k', 10000000);
173-
put((int) 'l', 10000000);
174-
put((int) 'm', 10000000);
175-
put((int) 'n', 10000000);
176-
put((int) 'o', 10000000);
177-
put((int) 'p', 10000000);
178-
put((int) 'q', 10000000);
179-
put((int) 'r', 10000000);
180-
put((int) 's', 10000000);
181-
put((int) 't', 10000000);
182-
put((int) 'u', 10000000);
183-
put((int) 'v', 10000000);
184-
put((int) 'w', 10000000);
185-
put((int) 'x', 10000000);
186-
put((int) 'y', 10000000);
187-
put((int) 'z', 10000000);
188-
}
189-
};
190-
191-
Map<Integer, Integer> multiCounts = multiThreadPool.submit(
192-
() -> (new ParallelLetterFrequency(b.toString()).letterCounts())
193-
).get();
194-
195-
boolean startedThreadCountEqualsPoolSize = allThreads.stream()
196-
.filter(thread -> thread.wasStarted)
197-
.count() == allThreads.size();
198-
199-
assertTrue(startedThreadCountEqualsPoolSize);
200-
}
201111
}

0 commit comments

Comments
 (0)