2

我已从“org.codehaus.gpars:gpars:1.0.0”更新为“org.codehaus.gpars:gpars:1.1.0”。我的代码在 1.0.0 中运行良好,但在 1.1.0 版中我再也找不到 jsr166y.ForkJoinPool 了。

如何获得正确的 ForkJoinPool?

我正在使用的代码是:

import groovyx.gpars.GParsPool
import jsr166y.ForkJoinPool

class Test {
   def pool = new ForkJoinPool()

   def executeAsync(args, closure = null) {
    if(!closure) {
        closure = args
        args = null
    }

    GParsPool.withExistingPool(pool) {
        closure.callAsync(args)
    }
   }
}

我必须导入 java.util.concurrent.ForkJoinPool 才能获得 ForkJoinPool 类。但在运行时我收到以下错误:

| Error 2013-08-01 13:26:45,807 [http-nio-8080-exec-4] ERROR 
errors.GrailsExceptionResolver  - ClassNotFoundException occurred when processing   
request: [POST] /testpackage/test/saveAll - parameters:
jsr166y.ForkJoinPool. Stacktrace follows: 
Message: jsr166y.ForkJoinPool
Line | Method
->>  175 | findClass                 in org.codehaus.groovy.tools.RootLoader
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
|    423 | loadClass                 in java.lang.ClassLoader
|    147 | loadClass . . . . . . . . in org.codehaus.groovy.tools.RootLoader
|    356 | loadClass                 in java.lang.ClassLoader
|   2451 | privateGetDeclaredMethods in java.lang.Class
|   1810 | getDeclaredMethods        in     ''
|     46 | getLocked . . . . . . . . in org.codehaus.groovy.util.LazyReference
|     33 | get                       in     ''
|    318 | saveAll . . . . . . . . . in testpackage.UploadImageController
|    195 | doFilter                  in   
grails.plugin.cache.web.filter.PageFragmentCachingFilter
|     63 | doFilter . . . . . . . .  in grails.plugin.cache.web.filter.AbstractFilter
|   1145 | runWorker                 in java.util.concurrent.ThreadPoolExecutor
|    615 | run . . . . . . . . . . . in java.util.concurrent.ThreadPoolExecutor$Worker
^    722 | run                       in java.lang.Thread
| Compiling 1 source files.
4

1 回答 1

4

将您的 BuildConfog.groovy 更新为:

compile 'org.codehaus.gpars:gpars:1.1.0'
compile 'org.codehaus.jsr166-mirror:jsr166y:1.7.0'

这应该适合你。

于 2013-08-01T13:58:25.260 回答