Concurrent包学习笔记--Callable

为何使用Callable?

Callable优势是相对于Runnable而言的,使用Runnable作为线程的执行器是不会返回结果的,而Callable作为执行器可以返回结果(也可以抛出异常),同时还可以对任务做一些操作和获取任务的当前状态。

Callable是如何实现这些功能的?

Callable实现上述的功能是通过Future这个接口的,注意ExecutorService包含三个方法

1. <T> Future<T>submit(Callable<T> task);
2. <T> Future<T> submit(Runnable task, T result);
3. Future<?> submit(Runnable task);

这3个方法中第一个和第三个比较常用,而由于Runnable的run()方法时没有返回值的,这就注定了返回的Future对象不可能拿到返回值。

dd

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
In Verilog, a non-net refers to a variable that is not a wire or a register, but rather a constant or a parameter. Concurrent assignment refers to the assignment of a value to a variable using the "=" operator in a module outside of any procedural blocks (such as always or initial blocks). A concurrent assignment to a non-net is not allowed in Verilog. This is because a non-net does not have a storage element and cannot hold a value assigned to it. Instead, it is typically used as a constant or a parameter that is available for use in the module. To assign a value to a non-net, it should be done within a procedural block using the appropriate assignment operator (such as "<=" for registers or "assign" for wires). Alternatively, the value can be passed as an argument to the module using the parameter keyword. For example: module my_module #(parameter WIDTH = 8) ( input clk, input [WIDTH-1:0] data_in, output [WIDTH-1:0] data_out ); // This is a non-net parameter parameter ADD_VALUE = 5; // This is a register that can be assigned using the "=" operator within an always block reg [WIDTH-1:0] register_data; always @(posedge clk) begin register_data <= data_in + ADD_VALUE; end // This is a wire that can be assigned using the "assign" keyword assign data_out = register_data; endmodule In this example, ADD_VALUE is a non-net parameter that is used in the always block to add a constant value to the input data. The register_data variable is assigned using the "=" operator within the always block. The data_out wire is assigned using the "assign" keyword.

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值