Mar 06, 2023 1:57:20 AM main.Main main
INFO: Story Outline Producer and Consumer Application
Mar 06, 2023 1:57:20 AM main.Main lambda$1
INFO: consumer-1 | Story Outline 0
Random THEME – Love conquers all
Random PLOT – Overcoming the Monster
Personification Informal Diction Informal Diction Onomatopoeia Imagery Allusion Euphemism Alliteration Metaphor Onomatopoeia
Random Villain Shark
Stone Elemental Tornado Dragon Skeleton Fire Elemental Tornado Earthquake Shark Banshee Lich Shark Ice Elemental Troll Vampire Bandit Earthquake Hurricane Fire Elemental Tornado Tornado
Descriptive Writing Amps
[beguiling, beguiling, violet] kilometer dashed
[colossal, kinetic, fluffy] star shifted
[angry, joyful, loud] demon encouraged
[memorable, tranquil, delicate] wave whispered
[biased, brilliant, daunting] kilometer opened
[sweet, potential, white] problem dashed
[vibrant, minuscule, soft] game provided
[red, blissful, potential] jaguar dodged
[microscopic, exalted, blissful] peace unfurled
[smooth, kinetic, cyan] thought encouraged
Random Hero – Rogue
And But Therefore Event Sets
Comet cuts across the sky but [Side character] shows up therefore they seek assistance with [side character]
diffuse a bomb but [monster] shows up therefore they travel to a new area
diffuse a bomb but [monster] shows up therefore they fight the [monster]
[Hero] gets on train but [monster] challenges [Hero] with hurtful scary words therefore they decide to learn more
There is a solar eclipse but they are delayed therefore they decide to learn more
fight a [monster] but [monster] challenges [Hero] with hurtful scary words therefore they fight the [monster]
Dramatic Dialogue with subtext but [Side character] shows up therefore they seek assistance with [side character]
[Hero] gets in spaceship but they are delayed therefore they seek assistance with [side character]
There is a solar eclipse but [Side character] shows up therefore they decide to learn more
[Hero] is Inspired and Encouraged by [side character] but they are delayed therefore they travel to a new area
Mar 06, 2023 1:57:20 AM main.Main lambda$1
INFO: consumer-2 | Story Outline 1
Random THEME – Oppression is wrong
Random PLOT – Quest
Imagery Flashback Allusion Personification Personification Personification Allusion Foreshadowing Allusion Onomatopoeia
Random Villain Fire Elemental
Ghost Tornado Fire Elemental Shark Ghost Giant Spider Banshee Kraken Fire Elemental Kraken Banshee Kraken Forest Fire Demon Forest Fire Kraken Troll Kraken Water Elemental Kraken
Descriptive Writing Amps
[gray, black, smooth] desert evaded
[proper, sweet, saturated] cliff communicated
[green, exalted, delightful] hyena provided
[delightful, joyful, important] gold halted
[colossal, cyan, black] angel closed
[toned, purple, blue] woods provided
[gray, efficient, kinetic] flamingo halted
[toned, tinted, yellow] puzzle gnashed
[efficient, vibrant, happy] gear evaded
[toned, magnificent, green] meter directed
Random Hero – Knight
And But Therefore Event Sets
Dramatic Dialogue with subtext but [Side character] shows up therefore they travel to a new area
[Hero] gets in supercar but they are delayed therefore they decide to learn more
Narration highlights allegory that amplifies key details worthy of memory but [monster] challenges [Hero] with hurtful scary words therefore they travel to a new area
[Hero] gets on train but they get there early therefore they decide to learn more
[Hero] gets on train but it rains therefore they travel to a new area
Narration highlights allegory that amplifies key details worthy of memory but they get there early therefore they fight the [monster]
[Hero] gets in bus but [monster] shows up therefore they decide to learn more
[Hero] gets in bus but it rains therefore they fight the [monster]
[Hero] gets on train but it rains therefore they fight the [monster]
[Hero] is given assistance from [side character] but it rains therefore they fight the [monster]
Mar 06, 2023 1:57:20 AM main.Main lambda$1
INFO: consumer-1 | Story Outline 3
Random THEME – Seize the day
Random PLOT – Comedy
Metaphor Metaphor Flashback Tone Euphemism Imagery Symbolism Flashback Metaphor Personification
Random Villain Kraken
Fire Elemental Banshee Forest Fire Water Elemental Ice Elemental Stone Elemental Troll Giant Spider Giant Banshee Stone Elemental Dragon Giant Troll Water Elemental Hurricane Forest Fire Bandit Dragon Ice Elemental
Descriptive Writing Amps
[beguiling, blue, minuscule] ratio whispered
[minuscule, towering, gargantuan] imagination wrote
[loud, gray, proper] mountain halted
[sad, shaded, smooth] moon evoked
[yellow, potential, tranquil] gas giant amplified
[toned, memorable, calm] blizzard enlightened
[black, green, blissful] woods amplified
[gray, microscopic, calm] puzzle closed
[memorable, green, gargantuan] kilometer refined
[sour, magnificent, magnificent] country whispered
Random Hero – Bard
And But Therefore Event Sets
[Hero] gets in supercar but [monster] shows up therefore they decide to learn more
[Hero] gets in jet but [monster] challenges [Hero] with hurtful scary words therefore they travel to a new area
[Hero] is given assistance from [side character] but [Side character] shows up therefore they travel to a new area
Comet cuts across the sky but they get there early therefore they travel to a new area
[Hero] is Inspired and Encouraged by [side character] but it rains therefore they fight the [monster]
[Hero] gets in bus but it rains therefore they fight the [monster]
[Hero] gets in supercar but they are delayed therefore they decide to learn more
Dramatic Dialogue with subtext but [monster] challenges [Hero] with hurtful scary words therefore they seek assistance with [side character]
[Hero] is given assistance from [side character] but they get there early therefore they seek assistance with [side character]
[Hero] gets in bus but [monster] shows up therefore they decide to learn more
Mar 06, 2023 1:57:20 AM main.Main lambda$1
INFO: consumer-2 | Story Outline 2
Random THEME – Seize the day
Random PLOT – Quest
Imagery Personification Euphemism Personification Formal Diction Onomatopoeia Simile Personification Imagery Informal Diction
Random Villain Water Elemental
Tornado Skeleton Bandit Kraken Forest Fire Kraken Siren Ice Elemental Ghost Ice Elemental Forest Fire Forest Fire Tornado Giant Forest Fire Lich Dragon Ice Elemental Bandit Water Elemental
Descriptive Writing Amps
[beguiling, beguiling, violet] desert sprinted
[daunting, colossal, blissful] cliff gnashed
[purple, beguiling, loud] monkey gnashed
[gargantuan, soft, joyful] angel painted
[monumental, exalted, gargantuan] game evoked
[tinted, soft, joyful] blackhole unfurled
[memorable, rough, beige] cliff unfurled
[joyful, violet, exalted] farm shifted
[rough, red, calm] mountain magnified
[yellow, colossal, delightful] kitten shouted
Random Hero – Wizard
And But Therefore Event Sets
[Hero] is given assistance from [side character] but they are delayed therefore they decide to learn more
Dramatic Dialogue with subtext but [monster] challenges [Hero] with hurtful scary words therefore they seek assistance with [side character]
Comet cuts across the sky but [monster] shows up therefore they travel to a new area
[Hero] is Inspired and Encouraged by [side character] but [Side character] shows up therefore they fight the [monster]
[Hero] gets in bus but they get there early therefore they decide to learn more
Dramatic Dialogue with subtext but they get there early therefore they decide to learn more
[Hero] is attacked by [Monster] but they are delayed therefore they seek assistance with [side character]
There is a solar eclipse but they are delayed therefore they travel to a new area
[Hero] gets on horse but [monster] shows up therefore they decide to learn more
[Hero] is given assistance from [side character] but they are delayed therefore they decide to learn more
Free Java Classes
package main.util;
import java.io.StringWriter;
import java.util.ArrayList;
import java.util.logging.Logger;
import java.util.random.RandomGenerator;
import java.util.random.RandomGeneratorFactory;
import java.util.stream.DoubleStream;
public class StoryOutlineUtil {
private static Logger logger = Logger.getLogger(StoryOutlineUtil.class.toString());
public static String generateStoryOutline() {
final StringWriter storyOutline = new StringWriter();
RandomGenerator randomGenerator = RandomGeneratorFactory.getDefault().create();
DoubleStream doubleStream = randomGenerator.doubles(10);
logger.fine("Random THEME - "+ThemeUtil.getRandomTheme());
storyOutline.write("Random THEME - "+ThemeUtil.getRandomTheme()+"\n");
logger.fine("Random PLOT - "+PlotUtil.getRandomPlot());
storyOutline.write("Random PLOT - "+PlotUtil.getRandomPlot()+"\n");
ArrayList<String> literaryDevices = LiteraryDevicesUtils.getLiteraryDevices();
final StringWriter logStringWriter = new StringWriter();
doubleStream.forEach((random) -> {
int value = Double.valueOf(literaryDevices.size()*random).intValue();
logStringWriter.append(literaryDevices.get(value)+" ");
});
storyOutline.write(logStringWriter.toString()+"\n");
logger.fine(logStringWriter.toString());
storyOutline.write("Random Villain "+VillainUtil.getRandomVillain()+"\n");
logger.fine("Random Villain "+VillainUtil.getRandomVillain());
ArrayList<String> randomVillains = RandomUtil.getRandomList(VillainUtil.getVillains(), 20);
final StringWriter villainStringWriter = new StringWriter();
randomVillains.forEach((villain) -> {
villainStringWriter.append(villain+" ");
});
storyOutline.write(villainStringWriter.toString()+"\n");
logger.fine(villainStringWriter.toString());
final StringWriter descriptivePhraseWriter = new StringWriter();
for (int i=0; i<10; i++) {
descriptivePhraseWriter.append(DescriptiveWritingUtil.getDescriptivePhrase()+'\n');
}
storyOutline.write("\nDescriptive Writing Amps\n");
logger.fine("Descriptive Writing Amps");
storyOutline.write(descriptivePhraseWriter.toString()+"\n");
logger.fine(descriptivePhraseWriter.toString());
storyOutline.write("Random Hero - "+HeroUtil.getRandomHero()+"\n");
logger.fine("Random Hero - "+HeroUtil.getRandomHero());
AndButThereforeEvent andButThereforeEventSet = new AndButThereforeEvent();
final StringWriter andButThereforeWriter = new StringWriter();
ArrayList<String> andButThereforeEventList = andButThereforeEventSet.getAndButThereforeEvents();
andButThereforeEventList.forEach((event) -> {
andButThereforeWriter.append(event+'\n');
});
logger.fine("And But Therefore Event Sets");
storyOutline.write("And But Therefore Event Sets\n");
logger.fine(andButThereforeWriter.toString());
storyOutline.write(andButThereforeWriter.toString());
return storyOutline.toString();
}
}
package main;
import java.util.concurrent.ConcurrentLinkedQueue;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.logging.Logger;
import main.util.StoryOutlineUtil;
import multithreading.ThreadUtil;
public class Main {
private static Logger logger = Logger.getLogger(Main.class.toString());
private static ConcurrentLinkedQueue<String> sharedQueue = new ConcurrentLinkedQueue<>();
private static AtomicInteger outlineCount = new AtomicInteger();
private static AtomicInteger consumerThreadCount = new AtomicInteger();
public static void main(String[] args) {
logger.info("Story Outline Producer and Consumer Application\n");
Thread producer = new Thread(storyOutlineProducer());
Thread consumer = new Thread(getConsumer());
ThreadUtil.addTask(producer);
ThreadUtil.addTask(producer);
ThreadUtil.addTask(producer);
ThreadUtil.addTask(producer);
ThreadUtil.addTask(consumer);
ThreadUtil.addTask(consumer);
}
public static Runnable storyOutlineProducer() {
Runnable storyOutlineProcess = () -> {
String storyOutline = "Story Outline "+outlineCount.getAndIncrement()+"\n";
storyOutline += StoryOutlineUtil.generateStoryOutline();
sharedQueue.add(storyOutline);
};
return storyOutlineProcess;
}
public static Runnable getConsumer() {
Runnable consumerRunnable = () -> {
String consumerId = "consumer-"+consumerThreadCount.incrementAndGet();
while (true) {
String element;
while (!sharedQueue.isEmpty()) {
element = sharedQueue.poll();
logger.info(consumerId+" | "+element);
}
try {
Thread.sleep(250);
} catch (InterruptedException e) {
logger.info("Consumer Sleep Interrupted: "+e.getMessage());
}
}
};
return consumerRunnable;
}
}
package multithreading;
import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
import java.util.logging.Logger;
public class ThreadUtil {
private static Logger logger = Logger.getLogger(ThreadUtil.class.toString());
private static BlockingQueue<Runnable> workQueue = new ArrayBlockingQueue<>(6);
private static ThreadPoolExecutor threadPoolExecutor;
public static BlockingQueue<Runnable> getWorkQueue() {
if (null == workQueue) {
workQueue = new ArrayBlockingQueue<>(6);
}
return workQueue;
}
public static ThreadPoolExecutor getThreadPool() {
if (null == threadPoolExecutor) {
threadPoolExecutor = new ThreadPoolExecutor(6, 12, 1000, TimeUnit.MILLISECONDS, getWorkQueue());
}
return threadPoolExecutor;
}
public static void addTask(Runnable task) {
getThreadPool().submit(task);
}
}
Set a loop to 1 million thus 4 million produced, the following was the last line of the log, 1 out of 4,000,000.
Mar 06, 2023 2:13:51 AM main.Main lambda$1
INFO: consumer-1 | Story Outline 3999997
Random THEME – Oppression is wrong
Random PLOT – Tragedy
Alliteration Informal Diction Informal Diction Symbolism Informal Diction Informal Diction Symbolism Imagery Allusion Euphemism
Random Villain Troll
Siren Troll Ghost Skeleton Dragon Ghost Troll Fire Elemental Tornado Demon Vampire Dragon Vampire Vampire Troll Hurricane Giant Banshee Vampire Ice Elemental
Descriptive Writing Amps
- [biased, potential, biased] cable commanded
- [important, exalted, fluffy] moon sprinted
- [loud, resonant, purple] hero enlightened
- [purple, shaded, blue] canvas shouted
- [microscopic, monumental, blue] neutron whispered
- [toned, fluffy, magnificent] beach transported
- [towering, saturated, rough] sugar encouraged
- [brilliant, gargantuan, exalted] peace typed
- [brilliant, delicate, beige] super-car directed
- [sweet, rough, proper] elk accelerated
Random Hero – Knight
And But Therefore Event Sets
- diffuse a bomb but it rains therefore they decide to learn more
- fight a [monster] but [monster] challenges [Hero] with hurtful scary words therefore they fight the [monster]
- [Hero] gets on motorcycle but [monster] shows up therefore they seek assistance with [side character]
- Dramatic Dialogue with subtext but [Side character] shows up therefore they travel to a new area
- [Hero] gets in jet but [monster] challenges [Hero] with hurtful scary words therefore they fight the [monster]
- There is a solar eclipse but [monster] shows up therefore they decide to learn more
- [Hero] is attacked by [Monster] but it rains therefore they decide to learn more
- There is a solar eclipse but it rains therefore they decide to learn more
- Comet cuts across the sky but they get there early therefore they decide to learn more
- Narration highlights allegory that amplifies key details worthy of memory but it rains therefore they travel to a new area