我声明我读过线程,但我从未使用过.所以我问你:)
我有两个线程:A和B,其中A管理GUI和B管理逻辑.
我会先说A.
然后在A绘制GUI时,我会暂停它,等待B到达X点进入run方法.
当B达到X点进入运行方法时,我暂停B,然后恢复A.
A并B共享一些变量来管理GUI,逻辑......
我可以做吗?如果有,怎么样?:)
我想知道是否有人可以帮助我如何实现一个在后台无限运行的线程,直到用户按下p,此时它会暂停其他线程并按下r恢复其他线程.这是一些代码
一些主要对象
public class CardGame
{
static Player[] players;
static int handSize;
static Queue<Card>[] playingDeckArray;
public static void main(String[] args){
Scanner reader = new Scanner(System.in);
System.out.println( "\nHello, how many players would you like" );
int playersNum = Integer.parseInt(Checks.userInputCheck( "\\d" ));
System.out.println( "\nHow many cards should each player begin with" );
int handSize = Integer.parseInt(Checks.userInputCheck( "\\d" ));
System.out.println( "\nWhich strategy would you like to use 1 or 2" );
int strategy = Integer.parseInt(Checks.userInputCheck( "[12]$" ));
Logger.createDeck( playersNum, handSize );
makePlayers( playersNum, …Run Code Online (Sandbox Code Playgroud)