我目前在Jenkins中使用“执行系统常规脚本”。我在Jenkins的编辑器框中编写了以下代码。
import hudson.model.*
import groovy.json.JsonBuilder
import groovy.json.JsonSlurper
// Get the list of all jobs and print them
activeJobs = hudson.model.Hudson.instance.items.findAll{job -> job.isBuildable()}
//activeJobs.each{run -> println(run.name)}
println ('total number of jobs :'+ activeJobs.size())
// find failed runs
failedRuns = activeJobs.findAll{job -> job.lastBuild != null && job.lastBuild.result == hudson.model.Result.FAILURE}
//failedRuns.each{run -> println(run.name)}
println ('total number of jobs :'+ failedRuns.size())
// find successful runs
successfulRuns = activeJobs.findAll{job -> job.lastBuild != null && job.lastBuild.result == hudson.model.Result.SUCCESS}
//successfulRuns.each{run -> println(run.name)}
println ('total number of jobs …Run Code Online (Sandbox Code Playgroud) 我试图将int转换为byte.
int i = 128;
byte b = (byte) i;
Run Code Online (Sandbox Code Playgroud)
我知道-128到127的字节范围以及将整数存储到一个字节的规则是:
byte_value = int_vale%byte_Range; (我发现在完整参考Java中)
当我将它应用于int 128时,它应该是这样的:
byte_value = 128%256 = 128;
但是,它实际上是:-128
我无法理解这背后的实际逻辑.请帮忙!!
我有这段代码.
public class Main{
public static void main(String[] args) {
Main1 main1 = new Main1();
Main2 main2 = new Main2();
Thread t1 = new Thread(main1);
Thread t2 = new Thread(main2);
t1.start();
t2.start();
}
}
public class Main1 extends Thread{
SynchronizedCounter c = new SynchronizedCounter();
public void run(){
System.out.println("Entering Main1");
c.print();
System.out.println("Exiting Main1");
}
}
public class Main2 extends Thread{
SynchronizedCounter c = new SynchronizedCounter();
public void run(){
System.out.println("Entering Main2");
c.print();
System.out.println("Exiting Main2");
}
}
public class SynchronizedCounter {
public void …Run Code Online (Sandbox Code Playgroud) 我正在尝试在 RCP 应用程序中创建一个最初不可见的标签。当我单击“保存”按钮时,它变得可见。同样,它应该在 5 秒内不可见。
为此,我编写了以下代码:
saveButton.addSelectionListener(new SelectionListener() {
@Override
public void widgetSelected(SelectionEvent e) {
// TODO Auto-generated method stub
System.out.println(textName.getText());
String text = textName.getText();
tree.getSelection()[0].setText(text);
String nodeId = ((TreeStructure) tree.getSelection()[0]
.getData()).getNodeId();
// update the database
UpdateTree updateTree = new UpdateTree();
updateTree.renameNode(text, nodeId);
label.setBounds(xForFirstButton, yIndexForButtons
+ Constants.BUTTON_BUFFER, Constants.BUTTON_WIDTH,
Constants.BUTTON_HEIGHT);
label.setVisible(true);
AbstractAction myAction = new AbstractAction() {
private static final long serialVersionUID = 1L;
@Override
public void actionPerformed(ActionEvent arg0) {
// TODO Auto-generated method stub
label.setVisible(false);
}
};
Timer myTimer = …Run Code Online (Sandbox Code Playgroud)