Reset author name to chosen name ✨
This commit is contained in:
@@ -1,86 +0,0 @@
|
||||
/*
|
||||
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
|
||||
* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
|
||||
*/
|
||||
package edu.slcc.asdv.chloe.multithreading_chloefontenot;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author chloe
|
||||
*/
|
||||
import javafx.application.Application;
|
||||
import javafx.application.Platform;
|
||||
import javafx.scene.Scene;
|
||||
import javafx.scene.control.Label;
|
||||
import javafx.scene.layout.StackPane;
|
||||
import javafx.stage.Stage;
|
||||
|
||||
public class FlashText extends Application
|
||||
{
|
||||
private String text = "";
|
||||
@Override // Override the start method in the Application class
|
||||
|
||||
public void start(Stage primaryStage)
|
||||
{
|
||||
StackPane pane = new StackPane();
|
||||
Label lblText = new Label("Programming is fun");
|
||||
pane.getChildren().add(lblText);
|
||||
|
||||
Thread t1 = new Thread(
|
||||
new Runnable()
|
||||
{
|
||||
public void run()
|
||||
{
|
||||
try
|
||||
{
|
||||
while (true)
|
||||
{
|
||||
if (lblText.getText().trim().length() == 0)
|
||||
text = "Welcome";
|
||||
else
|
||||
text = "";
|
||||
|
||||
|
||||
|
||||
Platform.runLater(
|
||||
new Runnable()
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
lblText.setText(text);
|
||||
}
|
||||
});
|
||||
|
||||
/*
|
||||
|
||||
Thread t2 =new Thread( new Runnable() {
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
lblText.setText(text);
|
||||
}
|
||||
});
|
||||
*/
|
||||
Thread.sleep(300);
|
||||
}
|
||||
}
|
||||
catch (InterruptedException ex)
|
||||
{
|
||||
}
|
||||
}
|
||||
});
|
||||
t1.start();
|
||||
|
||||
// Create a scene and place it in the stage
|
||||
Scene scene = new Scene(pane, 200, 50);
|
||||
primaryStage.setTitle("FlashText"); // Set the stage title
|
||||
primaryStage.setScene(scene); // Place the scene in the stage
|
||||
primaryStage.show(); // Display the stage
|
||||
}
|
||||
|
||||
public static void main(String[] args)
|
||||
{
|
||||
launch(args);
|
||||
}
|
||||
}
|
||||
@@ -1,59 +0,0 @@
|
||||
/*
|
||||
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
|
||||
* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
|
||||
*/
|
||||
package edu.slcc.asdv.chloe.multithreading_chloefontenot;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author chloe
|
||||
*/
|
||||
public class PrintChar implements Runnable{
|
||||
|
||||
private char charToPrint;
|
||||
private int times;
|
||||
|
||||
public PrintChar(char charToPrint, int times)
|
||||
{
|
||||
this.charToPrint = charToPrint;
|
||||
this.times = times;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
for (int i = 0; i < times; ++i) {
|
||||
System.out.println(charToPrint);
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String[] args)
|
||||
{
|
||||
for (int i = 0; i < 1000; ++i) {
|
||||
System.out.println("lmao");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class PrintNum implements Runnable {
|
||||
private int lastNum;
|
||||
|
||||
public PrintNum(int lastNum)
|
||||
{
|
||||
this.lastNum = lastNum;
|
||||
}
|
||||
|
||||
public void run()
|
||||
{
|
||||
for (int i = 1; i <= lastNum; ++i) {
|
||||
System.out.print(" " + i);
|
||||
Thread.yield();
|
||||
if (i % 10 == 0) {
|
||||
System.out.println();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -1,15 +0,0 @@
|
||||
/*
|
||||
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
|
||||
* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
|
||||
*/
|
||||
package edu.slcc.asdv.chloe.multithreading_chloefontenot;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author chloe
|
||||
*/
|
||||
public class RunFlash {
|
||||
public static void main(String[] args) {
|
||||
FlashText.main(args);
|
||||
}
|
||||
}
|
||||
@@ -1,29 +0,0 @@
|
||||
/*
|
||||
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
|
||||
* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
|
||||
*/
|
||||
package edu.slcc.asdv.chloe.multithreading_chloefontenot;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author chloe
|
||||
*/
|
||||
public class Threads {
|
||||
public static void main(String[] args)
|
||||
{
|
||||
// Create tasks
|
||||
Runnable printA = new PrintChar('a', 100);
|
||||
Runnable printB = new PrintChar('b', 100);
|
||||
Runnable print100 = new PrintNum(100);
|
||||
|
||||
// Create threads
|
||||
Thread thread1 = new Thread(printA);
|
||||
Thread thread2 = new Thread(printB);
|
||||
Thread thread3 = new Thread(print100);
|
||||
|
||||
// Start threads
|
||||
thread1.start();
|
||||
thread2.start();
|
||||
thread3.start();
|
||||
}
|
||||
}
|
||||
@@ -1,20 +0,0 @@
|
||||
/*
|
||||
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
|
||||
*/
|
||||
|
||||
package edu.slcc.asdv.chloe.multithreading_chloefontenot;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author chloe
|
||||
*/
|
||||
public class forkbomb
|
||||
{
|
||||
public static void main(String[] args) throws IOException
|
||||
{
|
||||
Runtime.getRuntime().exec(new String[]{"java", "-cp", System.getProperty("java.class.path"), "forkbomb"});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user