当前位置: 首页>>代码示例>>Java>>正文


Java RunnableFuture.run方法代码示例

本文整理汇总了Java中java.util.concurrent.RunnableFuture.run方法的典型用法代码示例。如果您正苦于以下问题:Java RunnableFuture.run方法的具体用法?Java RunnableFuture.run怎么用?Java RunnableFuture.run使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.util.concurrent.RunnableFuture的用法示例。


在下文中一共展示了RunnableFuture.run方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: resolve

import java.util.concurrent.RunnableFuture; //导入方法依赖的package包/类
@Override
public java.util.concurrent.Future<ProjectProblemsProvider.Result> resolve() {
    ProjectProblemsProvider.Result res;
    if (action != null) {
        action.actionPerformed(null);
        String text = (String) action.getValue(ACT_START_MESSAGE);
        if (text != null) {
            res = ProjectProblemsProvider.Result.create(ProjectProblemsProvider.Status.RESOLVED, text);
        } else {
            res = ProjectProblemsProvider.Result.create(ProjectProblemsProvider.Status.RESOLVED);
        }
    } else {
        res = ProjectProblemsProvider.Result.create(ProjectProblemsProvider.Status.UNRESOLVED, "No resolution for the problem");
    }
    RunnableFuture<ProjectProblemsProvider.Result> f = new FutureTask(new Runnable() {
        @Override
        public void run() {
        }
    }, res);
    f.run();
    return f;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:23,代码来源:JUnitProjectOpenedHook.java

示例2: processQueue

import java.util.concurrent.RunnableFuture; //导入方法依赖的package包/类
void processQueue()
{
   try
   {
      while (true && !shutdown && !checkEndThread())
      {
         do
         {
            RunnableFuture task = take();
            task.run();
         }
         while (queue.size() > 0);

         //            if (!shutdown)
         //            {
         //               Thread.sleep(delay);
         //            }
         //
         //            if (queue.size() == 0)
         //               break;
      }
   }
   catch (Exception ex)
   {
      ex.printStackTrace();
   }
}
 
开发者ID:wellsb1,项目名称:fort_j,代码行数:28,代码来源:Executor.java

示例3: beforeExecute

import java.util.concurrent.RunnableFuture; //导入方法依赖的package包/类
@Override
protected void beforeExecute(Thread thread, Runnable lowPriorityTask) {
    // Run all high priority tasks in queue first, then low priority
    RunnableFuture<?> priorityTask;
    while ( ( priorityTask = priorityTasks.poll() ) != null ) {
        priorityTask.run();
    }
    super.beforeExecute( thread, lowPriorityTask );
}
 
开发者ID:agroal,项目名称:agroal,代码行数:10,代码来源:PriorityScheduledExecutor.java

示例4: runIfNotDoneAndGet

import java.util.concurrent.RunnableFuture; //导入方法依赖的package包/类
public static <T> T runIfNotDoneAndGet(RunnableFuture<T> future) throws ExecutionException, InterruptedException {

		if (null == future) {
			return null;
		}

		if (!future.isDone()) {
			future.run();
		}

		return future.get();
	}
 
开发者ID:axbaretto,项目名称:flink,代码行数:13,代码来源:FutureUtil.java

示例5: resolve

import java.util.concurrent.RunnableFuture; //导入方法依赖的package包/类
@Override
@NbBundle.Messages({
    "LBL_ResolveProfile=Resolve Invalid Project Profile",
    "LBL_ResolveButton=OK",
    "AN_ResolveButton=Resolve",
    "AD_ResolveButton=Resolve the profile problems"
})
public Future<Result> resolve() {
    final JButton ok = new JButton(LBL_ResolveButton());
    ok.getAccessibleContext().setAccessibleName(AN_ResolveButton());
    ok.getAccessibleContext().setAccessibleDescription(AD_ResolveButton());
    final FixProfile panel = new FixProfile(ok, currentProfile, state);
    final DialogDescriptor dd = new DialogDescriptor(
            panel,
            LBL_ResolveProfile(),
            true,
            new Object[]{
        ok,
        DialogDescriptor.CANCEL_OPTION
    },
            ok,
            DialogDescriptor.DEFAULT_ALIGN,
            null,
            null);
    if (DialogDisplayer.getDefault().notify(dd) == ok) {
        return RP.submit(new Callable<ProjectProblemsProvider.Result>() {
            @Override
            public ProjectProblemsProvider.Result call() throws Exception {
                ProjectProblemsProvider.Status status = ProjectProblemsProvider.Status.UNRESOLVED;
                try {
                    ProjectManager.mutex().writeAccess(new Mutex.ExceptionAction<Void>() {
                        @Override
                        public Void run() throws IOException {
                            final boolean shouldUpdate = panel.shouldUpdateProfile();
                            if (shouldUpdate) {
                                final Profile newProfile = panel.getProfile();
                                final EditableProperties props = antProjectHelper.getProperties(AntProjectHelper.PROJECT_PROPERTIES_PATH);
                                if (newProfile == null ||
                                    newProfile == Profile.DEFAULT) {
                                    props.remove(profileProperty);
                                } else {
                                    props.put(profileProperty, newProfile.getName());
                                }
                                antProjectHelper.putProperties(AntProjectHelper.PROJECT_PROPERTIES_PATH, props);
                            }
                            for (Reference rootToRemove : panel.getRootsToRemove()) {
                                rootToRemove.remove(antProjectHelper);
                            }
                            ProjectManager.getDefault().saveProject(
                                    FileOwnerQuery.getOwner(antProjectHelper.getProjectDirectory()));
                            return null;
                        }
                    });
                    status = ProjectProblemsProvider.Status.RESOLVED;
                } catch (MutexException e) {
                    Exceptions.printStackTrace(e);
                }
                return ProjectProblemsProvider.Result.create(status);
            }
        });
    }
    final RunnableFuture<Result> res = new FutureTask<Result>(
            new Callable<Result>() {
                @Override
                public Result call() {
                    return ProjectProblemsProvider.Result.create(ProjectProblemsProvider.Status.UNRESOLVED);
                }
            });
    res.run();
    return res;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:72,代码来源:ProfileProblemsProviderImpl.java

示例6: setUp

import java.util.concurrent.RunnableFuture; //导入方法依赖的package包/类
@Override
protected void setUp() throws Exception {
    super.setUp();
    this.clearWorkDir();
    final RunnableFuture<Project[]> dummyFuture = new FutureTask<>(new Callable<Project[]>() {
        @Override
        public Project[] call() throws Exception {
            return new Project[0];
        }
    });
    dummyFuture.run();
    assertTrue(dummyFuture.isDone());
    OpenProject.future = dummyFuture;
    FileObject workDir = FileUtil.toFileObject(this.getWorkDir());
    assertNotNull("MasterFS is not configured.", workDir);
    this.srcRoot = workDir.createFolder("src");
    this.compileRoots = new FileObject[3];
    for (int i=0; i< this.compileRoots.length; i++) {
        this.compileRoots[i] = workDir.createFolder("lib_"+Integer.toString(i));
    }
    ClassPath cp = ClassPathSupport.createClassPath(this.compileRoots);
    GlobalPathRegistry.getDefault().register(ClassPath.COMPILE, new ClassPath[] {cp});
   this.execRoots = new FileObject[2];
    this.execRoots[0] = this.compileRoots[2];
    this.execRoots[1] = workDir.createFolder("lib_OnlyExec");
    cp = ClassPathSupport.createClassPath(this.execRoots);
    GlobalPathRegistry.getDefault().register (ClassPath.EXECUTE, new ClassPath[]{cp});
    this.libSourceRoots = new FileObject[2];
    for (int i=0; i< libSourceRoots.length; i++) {
        this.libSourceRoots[i] = workDir.createFolder ("libSrc_"+Integer.toString(i));
    }
    cp = ClassPathSupport.createClassPath (this.libSourceRoots);
    GlobalPathRegistry.getDefault().register (ClassPath.SOURCE, new ClassPath[]{cp});
    execTestDir = workDir.createFolder("exec");

    FileObject java9 = FileUtil.createFolder(workDir, "java9"); //NOI18N
    FileObject javaBase = FileUtil.createFolder(java9, "modules/java.base"); //NOI18N
    j9 = new J9(java9, javaBase);
    Lookup.getDefault().lookup(JavaPlatformProviderImpl.class).addPlatform(j9);
    Lookup.getDefault().lookup(MockSLQ.class).reset();
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:42,代码来源:DefaultClassPathProviderTest.java

示例7: testEvents

import java.util.concurrent.RunnableFuture; //导入方法依赖的package包/类
/**
 * Checks that single event is fired during opening (closing) of projects
 */
public void testEvents() throws Exception {
    final File wd = getWorkDir();
    final File root1 = FileUtil.normalizeFile(new File (wd,"src1"));    //NOI18N
    final File root2 = FileUtil.normalizeFile(new File (wd,"src2"));    //NOI18N
    root1.mkdir();
    root2.mkdir();
    final ClassPathProvider cpp = new DefaultClassPathProvider ();
    final ClassPath defaultCompile = cpp.findClassPath(FileUtil.toFileObject(wd), ClassPath.COMPILE);
    assertNotNull(defaultCompile);
    assertFalse(contains(defaultCompile, Utilities.toURI(root1).toURL()));
    assertFalse(contains(defaultCompile, Utilities.toURI(root2).toURL()));
    final Listener listener = new Listener();
    defaultCompile.addPropertyChangeListener(listener);
    final GlobalPathRegistry regs = GlobalPathRegistry.getDefault();
    final ClassPath compileCpProject1 = ClassPathSupport.createClassPath(Utilities.toURI(root1).toURL());
    final ClassPath compileCpProject2 = ClassPathSupport.createClassPath(Utilities.toURI(root2).toURL());
    
    //Simulate projects open
    RunnableFuture<Project[]> barrier = new FutureTask<Project[]>(new Callable<Project[]>() {
        @Override
        public Project[] call() throws Exception {
            return new Project[0];
        }
    });
    OpenProject.future = barrier;

    regs.register(ClassPath.COMPILE, new ClassPath[]{compileCpProject1});
    assertFalse(contains(defaultCompile, Utilities.toURI(root1).toURL()));
    assertFalse(listener.awaitEvent());
    assertEquals(0, listener.get());
    regs.register(ClassPath.COMPILE, new ClassPath[]{compileCpProject2});
    assertFalse(contains(defaultCompile, Utilities.toURI(root2).toURL()));
    assertFalse(listener.awaitEvent());
    assertEquals(0, listener.get());
    barrier.run();
    assertTrue(listener.awaitEvent());
    assertEquals(1, listener.get());
    assertTrue(contains(defaultCompile, Utilities.toURI(root1).toURL()));
    assertTrue(contains(defaultCompile, Utilities.toURI(root2).toURL()));

    //Simulate projects close
    barrier = new FutureTask<Project[]>(new Callable<Project[]>() {
        @Override
        public Project[] call() throws Exception {
            return new Project[0];
        }
    });
    OpenProject.future = barrier;
    listener.reset();
    regs.unregister(ClassPath.COMPILE, new ClassPath[]{compileCpProject1});
    assertTrue(contains(defaultCompile, Utilities.toURI(root1).toURL()));
    assertFalse(listener.awaitEvent());
    assertEquals(0, listener.get());
    regs.unregister(ClassPath.COMPILE, new ClassPath[]{compileCpProject2});
    assertTrue(contains(defaultCompile, Utilities.toURI(root2).toURL()));
    assertFalse(listener.awaitEvent());
    assertEquals(0, listener.get());
    barrier.run();
    assertTrue(listener.awaitEvent());
    assertEquals(1, listener.get());
    assertFalse(contains(defaultCompile, Utilities.toURI(root1).toURL()));
    assertFalse(contains(defaultCompile, Utilities.toURI(root2).toURL()));
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:67,代码来源:DefaultClassPathProviderTest.java

示例8: testSharedIncrementalStateDeRegistration

import java.util.concurrent.RunnableFuture; //导入方法依赖的package包/类
@Test
public void testSharedIncrementalStateDeRegistration() throws Exception {
	if (enableIncrementalCheckpointing) {
		AbstractKeyedStateBackend<Integer> backend = createKeyedBackend(IntSerializer.INSTANCE);
		try {
			ValueStateDescriptor<String> kvId =
				new ValueStateDescriptor<>("id", String.class, null);

			kvId.initializeSerializerUnlessSet(new ExecutionConfig());

			ValueState<String> state =
				backend.getPartitionedState(VoidNamespace.INSTANCE, VoidNamespaceSerializer.INSTANCE, kvId);

			Queue<IncrementalKeyedStateHandle> previousStateHandles = new LinkedList<>();
			SharedStateRegistry sharedStateRegistry = spy(new SharedStateRegistry());
			for (int checkpointId = 0; checkpointId < 3; ++checkpointId) {

				reset(sharedStateRegistry);

				backend.setCurrentKey(checkpointId);
				state.update("Hello-" + checkpointId);

				RunnableFuture<KeyedStateHandle> snapshot = backend.snapshot(
					checkpointId,
					checkpointId,
					createStreamFactory(),
					CheckpointOptions.forCheckpoint());

				snapshot.run();

				IncrementalKeyedStateHandle stateHandle = (IncrementalKeyedStateHandle) snapshot.get();
				Map<StateHandleID, StreamStateHandle> sharedState =
					new HashMap<>(stateHandle.getSharedState());

				stateHandle.registerSharedStates(sharedStateRegistry);

				for (Map.Entry<StateHandleID, StreamStateHandle> e : sharedState.entrySet()) {
					verify(sharedStateRegistry).registerReference(
						stateHandle.createSharedStateRegistryKeyFromFileName(e.getKey()),
						e.getValue());
				}

				previousStateHandles.add(stateHandle);
				backend.notifyCheckpointComplete(checkpointId);

				//-----------------------------------------------------------------

				if (previousStateHandles.size() > 1) {
					checkRemove(previousStateHandles.remove(), sharedStateRegistry);
				}
			}

			while (!previousStateHandles.isEmpty()) {

				reset(sharedStateRegistry);

				checkRemove(previousStateHandles.remove(), sharedStateRegistry);
			}
		} finally {
			IOUtils.closeQuietly(backend);
			backend.dispose();
		}
	}
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:65,代码来源:RocksDBStateBackendTest.java


注:本文中的java.util.concurrent.RunnableFuture.run方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。