我QCommandLineOption 用来解析我的commande行选项.
这是我的Arguments班级:
#include "arguments.h"
#include <QDebug>
/**
* @brief Constructor, need to know QApplication pointer
* @param app
*/
Arguments::Arguments(QApplication *app)
{
parser.setApplicationDescription("Convert html doc to pdf");
parser.addHelpOption();
parser.addVersionOption();
parser.addPositionalArgument("source", QApplication::translate("main", "Source file to copy."));
parser.addPositionalArgument("destination", QApplication::translate("main", "Destination file (ie /home/morgan/test.pdf)"));
setOption();
// Process the actual command line arguments given by the user
parser.process(*app);
args = parser.positionalArguments();
}
/**
* @brief Arguments::getSource
* @return QString the full path to file to be converted
*/
QString Arguments::getSource() …Run Code Online (Sandbox Code Playgroud) 我有一个小问题.
我有两个主题:
HelloThread - 这打印"你好"五次.GoodbyeThread - 这五次打印"再见".我想先跑,HelloThread然后GoodbyeThread跑完了.
我已经用信号量解决了这个问题(但信号量并不是真正的java方式,它更多的是C方式).
HelloThread.java /*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package modifiedthreadhellogoodbye;
import static java.lang.Thread.sleep;
import java.util.logging.Level;
import java.util.logging.Logger;
import java.util.concurrent.Semaphore;
class HelloThread implements Runnable {
private final Object lock;
//private final Semaphore lock;
public HelloThread(Semaphore lock) {
this.lock = lock;
}
public …Run Code Online (Sandbox Code Playgroud)