在Java中,我有必要实现一个在另一个类似的类中扩展Thread的类.那可能吗?
我想要做的一个例子是以下(简化)片段:
// The first layer is a Thread
public class Consumer extends Thread {
// Variables initialized correctly in the Creator
private BufferManager BProducer = null;
static class Mutex extends Object {}
static private Mutex sharedMutex = null;
public Consumer() {
// Initialization of the thread
sharedMutex = new Mutex();
BProducer = new BProducer(sharedMutex);
BProducer.start();
}
public void run() {
int data = BProducer.getData();
///// .... other operations
}
////// ...... some code
// Also the second layer is …Run Code Online (Sandbox Code Playgroud) 我对分配给图表值的标签有疑问.
该图是一个时间序列.我使用c3js的'columns'属性添加值.
我使用纯时间戳(以秒为单位),然后使用label.format将它们转换为字符串.
但是,这是发生的事情:
https://drive.google.com/file/d/0B9GDftIYQFIVb2Z3N2JfS2pzVjg/view?usp=sharing
你可以注意到空间分布不均,10月18日至21日,28日至28日,11月1日至4日,4月4日至7日,而其他所有日期均为3天.
是什么造成的?
我希望有均匀的间隙(相同的天数).
这是一个代码的jfiddle: http ://jsfiddle.net/ok1k6yjo/
var array_times = [1414540800, 1414627200];
var array_values = [67, 66.22];
var labelWeight = 'weight in kg';
var window_period = (30 * 24 * 3600); // last 30 days
var today = Math.floor(new Date(2014,10,20,0,0,0,0).getTime() / 1000);
var timeEnd = today;
var timeStart = today - window_period;
var toShowTime = [1414540800, 1414627200];
var toShowValues = [67, 66.22];
var minT = Math.min.apply(null, array_times),
maxT = Math.max.apply(null, array_times.concat(today));
var minV = Math.min.apply(null, …Run Code Online (Sandbox Code Playgroud) 在Java(Android)中是否可以实现自带状态的自定义版本的Thread?
我的意思是:当ThreadA处于Running状态时,它仍然可以被ThreadB轮询,询问它的状态
e.g.
ThreadA.getState();
Run Code Online (Sandbox Code Playgroud)
可以将状态值修改为某些自定义值吗?那么在这两个线程之间实现一种基本的通信系统呢?
谢谢.