小编CRo*_*eld的帖子

与关联的提供商创建 Pico 进程

我最近开始研究 Pico 进程的主题(请参阅此处此处)。我也开始看书了Windows Internals 7th Edition Part 1

正如书中所述,目前没有可用于创建自定义 Pico 流程和提供程序的 API。但是,我认为可以从内核驱动程序中创建 Pico 进程或提供程序,因为 Pico 进程的定义声明为:

[...] the idea of a Pico provider is defined, which is a custom kernel-mode driver that receives access to specialized kernel interfaces through the PsRegisterPicoProvider API.- Windows 内部结构第 7 版第 1 部分,第 14 页 68

不幸的是,当在 Visual Studio 2015 中创建新的内核模式驱动程序时,就像此处描述的那样,似乎没有任何可用的标头或接口允许创建 Pico 进程和提供程序。我似乎只能编写其他类型的 KMDF 项目。

目前,开发人员有什么方法可以在 Windows 中创建和测试自定义 Pico 进程和提供程序吗?

windows process windows-10 visual-studio-2015

6
推荐指数
1
解决办法
1452
查看次数

在 ScheduledThreadPoolExecutor 中使用 PriorityBlockingQueue 和 Comparator

首先:我已经阅读了以下两个问题及其可能的解决方案:

我遇到的困境是我想使用自定义队列BlockingQueue,或者更确切地说,使用不同但特定的队列,即PriorityBlockingQueue使用自定义队列Comparator使用按优先级对队列进行排序的自定义

ThreadPoolExecutor确实支持在其构造函数中自定义队列,但它不实现接口中的方法ScheduledExecutorService。所以我去找了子类ScheduledThreadPoolExecutor,但它不支持自定义队列并使用DelayedWorkQueue

问题:

  • 我无法扩展,ScheduledThreadPoolExecutor因为为我自己的类创建构造函数不会做任何事情,因为ScheduledThreadPoolExecutor不接受自定义队列作为参数。
  • 我无法复制类的内容ThreadPoolExecutor和实现,ScheduledThreadPoolExecutor因为它使用了许多没有修饰符声明的方法(例如canRunInCurrentState(boolean periodic),此调用调用的所有方法),这不允许我访问该方法,因为即使它的子类ThreadPoolExecutor,它不在同一个包中。

我当前的实现如下所示:

import java.util.concurrent.BlockingQueue;
import java.util.concurrent.Callable;
import java.util.concurrent.PriorityBlockingQueue;
import java.util.concurrent.RejectedExecutionHandler;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.ThreadFactory;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

import com.croemheld.tasks.PriorityTaskComparator;

public class ScheduledPriorityThreadPoolExecutor extends ThreadPoolExecutor implements ScheduledExecutorService {

    private static final int INITIAL_QUEUE_SIZE = 10;

    public ScheduledPriorityThreadPoolExecutor(int corePoolSize, int maximumPoolSize, …
Run Code Online (Sandbox Code Playgroud)

java multithreading blockingqueue scheduledexecutorservice

5
推荐指数
1
解决办法
1660
查看次数

添加转换为相同类型

我有一个外类DoublyLinkedList<T>和两个内部类DoublyLinkedNode<T>以及DoublyLinkedListIterator<T>.它们的安排如下:

public class DoublyLinkedList<T> extends Collection<T> {

    private DoublyLinkedNode<T> head;
    private DoublyLinkedNode<T> tail;

    public class DoublyLinkedNode<T> {

        private DoublyLinkedNode<T> prev;
        private DoublyLinkedNode<T> next;
        T element;

    }

    public class DoublyLinkedListIterator<T> implements ListIterator<T> {

        private DoublyLinkedNode<T> current = head;

    }

}
Run Code Online (Sandbox Code Playgroud)

现在,因为我在stackoverflow和其他来源的多个页面上听到/读取Iterator应该在相应的可迭代类中实现DoublyLinkedList<T>,我认为这样会更容易,因为您可以访问外部类字段.现在我想初始化一个实例DoublyLinkedListIterator<T>,但Eclipse在这一点上说:

private DoublyLinkedNode<T> current = head;
Run Code Online (Sandbox Code Playgroud)

在里面DoublyLinkedListIterator<T>:

类型不匹配:无法从DoublyLinkedList.DoublyLinkedNode <T>转换为DoublyLinkedList.DoublyLinkedNode <T>

解决这个问题的唯一方法是再次使用相同的类型:

private DoublyLinkedNode<T> current = (DoublyLinkedNode<T>) head;
Run Code Online (Sandbox Code Playgroud)

为什么会这样?

java casting

3
推荐指数
1
解决办法
245
查看次数