Computers - Feedback and Filp-Flops

Introduction
ToDo

What is an Oscillator?
The oscillator role in a circuit is simple and easy to understand. An oscillator alternates the state of a signal at a set intervals and play the role of a clock inside a circuit. Let's say an oscillator has a fluctuates between a one and a zero at the rate of 5 milliseconds. The cycle speed of this oscillator would run at 10 milliseconds. Let's say the signal coming from the oscillator is at zero. Five millisecond from then the oscillator will be transmitting an one, and in another five milliseconds the oscillator will be transmitting a zero again.

Emulating an Oscillator
This oscillator emulator is very much an incomplete hack. I wanted to avoid getting into threads and make this as few lines of code as possible. This factory method version contains a one-liner that accomplish (fingers crossed) this task. I decided to make use of the host computer's time and modular division.

Calling System.currentTimeMillis may give you a long value similar to this, 2109876543210. Using a little bit of modular math, we can ignore everything past second digit. A second is 1000 milliseconds, so in this example the number 3 is the place holder of the current second. Modular division is always a handle thing to know but in this case we can mod the system time by 10000. The result would be 3210.

Here is where I get lazy. I made a method called getState that used an if statement to check if the value is less than 5000. If this is true then getState returns a Boolean true value, if not, then a Boolean false value. If five seconds is too slow for you, I've also included an another version that alternates every second.

To be honest I'm not sure if this was the best design. This oscillator object does introduce can introduce some entropy into a sudo circuit but might fall on it's face when I try to incorporate it as a clock. Right now I have my fingers crossed if this fully works out well. If not, then this code could easily turn into a Java project that only Rube Goldberg could find appealing. Worst case, I'll have to quickly rewrite this in Python, if all else fails, then Lisp. ;)

public class Oscillator{ private static boolean signal; private Oscillator{} // A mod hack to alternate the signal every 5 seconds. public static boolean getSignal{ return(( (System.currentTimeMillis % 10000) < 5000 ) ? true : false ); }    /*      // A mod hack to alternate the signal every second. // UNTESTED!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! public static boolean getSignal{ int second = (System.currentTimeMillis % 10000) / 1000; return( (second % 2 != 0 ) ? true ? false ); }     */ }

What is a Feedback
ToDo

What is a Flip-Flop?
ToDo

Designing a Flip-Flop Circuit
ToDo

Emulating an Flip-Flop Circuit
ToDo