Promise<List<WrapSpec>> wrapSpecPromise = new Job() {
                @Override
                public List<WrapSpec> doJobWithResult() throws Exception {
                    return PkgLoad.findDistinctWrapSpecBetweenDates(pkgLine, startDate, endDate);
                }
            }.now();


是否可以将值pkgLine,startDate,endDate传递给此方法?谢谢你的帮助。

编辑:这是建议吗?或不。谢谢。

    for ( final PkgLine pkgLine : pkgLineList ) {


            Promise<List<WrapSpec>> distinctWrapPromise = new Job() {

                @Override
                public List<WrapSpec> doJobWithResult() throws Exception {
                    return PkgLoad.findDistinctWrapSpecBetweenDates( pkgLine, startDate, endDate );
                }
            }.now();
            promiseList.add( distinctWrapPromise );
        }

最佳答案

是的,如果在调用块中将它们声明为final

final PkgLine pkgLine = ...;
final Date startDate = ...;
final Date endDate = ...;

Promise<List<WrapSpec>> wrapSpecPromise =
  new Job() {
    @Override
    public List<WrapSpec> doJobWithResult() throws Exception {
      return
        PkgLoad.findDistinctWrapSpecBetweenDates(
          pkgLine,
          startDate,
          endDate
        );
    }
  }.now();

10-04 19:28