SAFE Logo
CodeMatch Detailed Report
Version: 5.6.0 | Date: 06/18/12 | Time: 19:09:04

SCORE

SETTINGS
Compare file 1: C:\Users\Evan\Desktop\Java2SE5.0\src\java\util\concurrent\AbstractExecutorService.java
To file 2: C:\Users\Evan\Desktop\Android2.2Froyo\java\util\concurrent\AbstractExecutorService.java
Links to results: Matching Statements
Matching Comments and Strings
Matching Instruction Sequences
Matching Identifiers
Partially Matching Identifiers
Score
RESULTS
Matching Statements
File1 Line# File2 Line# Statement
87package java.util.concurrent
108import java.util.*
2624public abstract class AbstractExecutorService implements ExecutorService {
2830public Future<?> submit(Runnable task) {
29
36
43
31
42
53
if (task == null) throw new NullPointerException()
3032FutureTask<Object> ftask = new FutureTask<Object>(task, null)
31
38
45
33
44
55
execute(ftask)
32
39
46
34
45
56
return ftask
3541public <T> Future<T> submit(Runnable task, T result) {
3743FutureTask<T> ftask = new FutureTask<T>(task, result)
4252public <T> Future<T> submit(Callable<T> task) {
4454FutureTask<T> ftask = new FutureTask<T>(task)
5262private <T> T doInvokeAny(Collection<Callable<T>> tasks,
5363boolean timed, long nanos)
54
139
64
149
throws InterruptedException, ExecutionException, TimeoutException {
55
145
65
155
if (tasks == null)
56
146
177
66
156
187
throw new NullPointerException()
5767int ntasks = tasks.size()
5868if (ntasks == 0)
5969throw new IllegalArgumentException()
6070List<Future<T>> futures= new ArrayList<Future<T>>(ntasks)
6171ExecutorCompletionService<T> ecs =
6272new ExecutorCompletionService<T>(this)
7383ExecutionException ee = null
7484long lastTime = (timed)? System.nanoTime() : 0
7585Iterator<Callable<T>> it = tasks.iterator()
78
87
88
97
futures.add(ecs.submit(it.next()))
79
86
89
96
--ntasks
8090int active = 1
8393Future<T> f = ecs.poll()
8494if (f == null) {
8595if (ntasks > 0) {
8898++active
90100else if (active == 0)
92102else if (timed) {
93103f = ecs.poll(nanos, TimeUnit.NANOSECONDS)
94104if (f == null)
95105throw new TimeoutException()
96
192
210
106
202
220
long now = System.nanoTime()
97
193
211
107
203
221
nanos -= now - lastTime
98
194
212
108
204
222
lastTime = now
101111f = ecs.take()
103113if (f != null) {
104114--active
106116return f.get()
107117} catch(InterruptedException ie) {
108118throw ie
109119} catch(ExecutionException eex) {
110120ee = eex
111121} catch(RuntimeException rex) {
112122ee = new ExecutionException(rex)
117127if (ee == null)
118128ee = new ExecutionException()
119129throw ee
122
168
219
132
178
229
for (Future<T> f : futures)
123
169
220
133
179
230
f.cancel(true)
127137public <T> T invokeAny(Collection<Callable<T>> tasks)
128138throws InterruptedException, ExecutionException {
130140return doInvokeAny(tasks, false, 0)
131141} catch (TimeoutException cannotHappen) {
132142assert false
137147public <T> T invokeAny(Collection<Callable<T>> tasks,
138
174
148
184
long timeout, TimeUnit unit)
140150return doInvokeAny(tasks, true, unit.toNanos(timeout))
143153public <T> List<Future<T>> invokeAll(Collection<Callable<T>> tasks)
144
175
154
185
throws InterruptedException {
147
179
157
189
List<Future<T>> futures = new ArrayList<Future<T>>(tasks.size())
148
180
158
190
boolean done = false
150160for (Callable<T> t : tasks) {
151161FutureTask<T> f = new FutureTask<T>(t)
152162futures.add(f)
153163execute(f)
155
199
165
209
for (Future<T> f : futures) {
156
200
166
210
if (!f.isDone()) {
158168f.get()
159
205
169
215
} catch(CancellationException ignore) {
160
206
170
216
} catch(ExecutionException ignore) {
164
215
174
225
done = true
165
196
202
208
216
175
206
212
218
226
return futures
167
218
177
228
if (!done)
173183public <T> List<Future<T>> invokeAll(Collection<Callable<T>> tasks,
176186if (tasks == null || unit == null)
178188long nanos = unit.toNanos(timeout)
182192for (Callable<T> t : tasks)
183193futures.add(new FutureTask<T>(t))
185195long lastTime = System.nanoTime()
189199Iterator<Future<T>> it = futures.iterator()
190200while (it.hasNext()) {
191201execute((Runnable)(it.next()))
195
201
205
211
if (nanos <= 0)
204214f.get(nanos, TimeUnit.NANOSECONDS)
207217} catch(TimeoutException toe) {

to top

Matching Comments and Strings
File1 Line# File2 Line# Comment/String
1412* execution methods. This class implements the <tt>submit</tt>,
1513* <tt>invokeAny</tt> and <tt>invokeAll</tt> methods using the default
1614* {@link FutureTask} class provided in this package. For example,
1715* the implementation of <tt>submit(Runnable)</tt> creates an
1816* associated <tt>FutureTask</tt> that is executed and
1917* returned. Subclasses overriding these methods to use different
2018* {@link Future} implementations should do so consistently for each
2119* of these methods.
2321* @since 1.5
2422* @author Doug Lea
5060* the main mechanics of invokeAny.
6474For efficiency, especially in executors with limited
6575parallelism, check to see if previously submitted tasks are
6676done before submitting more of them. This interleaving
6777plus the exception mechanics account for messiness of main
6878loop.
7181Record exceptions so that if we fail to obtain any
7282result, we can throw the last exception we got.
7787Start one task for sure; the rest incrementally
187197Interleave time checks and calls to execute in case
188198executor doesn't have any/much parallelism.

to top

Matching Instruction Sequences
File1 Line# File2 Line# Number of matching instructions
8 7 143
28 41 10
35 30 10

to top

Matching Identifiers
AbstractExecutorService active add ArrayList assert Callable cancel CancellationException
cannotHappen Collection concurrent doInvokeAny done ecs ee eex
execute ExecutionException ExecutorCompletionService ExecutorService ftask Future futures FutureTask
get hasNext ie ignore IllegalArgumentException InterruptedException invokeAll invokeAny
isDone it Iterator java lastTime List nanos NANOSECONDS
nanoTime next now ntasks NullPointerException Object poll result
rex Runnable RuntimeException size submit System take task
tasks timed timeout TimeoutException TimeUnit toe toNanos unit
util

to top

Partially Matching Identifiers
*** NONE ***
to the top
SCORE 96

CodeSuite copyright 2003-2012 by Software Analysis and Forensic Engineering Corporation