background preloader

Processing

Facebook Twitter

Issue with Processing + Ubuntu 10.10 + OpenJDK Plugin. Threading. From Processing This tutorial is based on my (somewhat outdated) Java tutorial about threads: The source code below from the examples below can be downloaded from here: Other Resources: You are likely familiar with the idea of writing a program that follows a specific sequence of steps -- setup() first then draw() over and over and over again! Processing does this all the time, whenever you write an event callback, such as serialEvent(), or captureEvent(), etc. these functions are triggered by a different thread running behind the scenes, and they alert Processing whenever they have something to report.

Void setup() { size(200,200); thread("someFunction");} void draw() { } void someFunction() { // This function will run as a thread when called via // thread("someFunction") as it was in setup!} The thread() function receives a String as an argument. Boolean running; // Is the thread running? Threads at daniel shiffman. If you are looking for a tutorial about using threads in Processing, I’ve adapted this page on the Processing wiki: Examples: Related: Java Threads tutorial Exercises (optional): Rewrite the spider so that each URL request is its own thread.Recreate one of your previous exercises as a Processing library.

Threading We’re quite familiar with the idea of writing a program that follows a specific sequence of steps as outlined in, say, a main() function. This is incredibly useful when it comes to data mining, as we can have separate threads retrieving different pieces of information from the network. Public class SimpleThread extends Thread { It’s useful to include a few fields describing the thread’s properties. Private boolean running; // Is the thread running? We are then going to override two functions from the parent Thread class: start() — Start causes the thread to begin its execution. Synchronized Threads Non threaded version Threaded version Full source: Inside the Hotspot VM: Clocks, Timers and Scheduling Events - Part I - Windows : David Holmes' Weblog. Clocks and Timers - General Overview There are two kinds of time related devices in a system: a means to read a time value; anda means to schedule/trigger a time related event The term "clock" is often used to refer to both of these because you read the time from a clock, and you can (often) set an alarm to have something happen when the clock reaches a certain time.

Sometimes the term "passive clock" is used for a time source that can only be read, while "active clock" is used for one that can also trigger an event/interrupt/alarm. For the sake of discussion (and because they are different hardware devices) I will use the term "clock" to refer to the means by which a time value can be read, and the term "timer" for something that can trigger a time-related event. To further complicate things both clocks and timers can be defined in absolute or relative terms. An absolute time relates to some external time reference (such as UTC) while a relative time is just an elapsed interval.

Floating Processing clouds with minim. I made a simple example to test the sound input features of minim, an audio library for processing. I took one of the cloudes i wrote for my ical-flowers and wrote a simple sketch that makes it float to the right whenever someone blows into the microphone. I didn't export it as an applet this time, but here is the code, in case you want to try it. Read/Write HTML field values from Java - Real's Java How-to.

Read/Write HTML field values from JAVATag(s): Javascript interaction [Netscape AND IE4 compatible] The netscape.javascript.* (LiveConnect) package provides facilities to directly manipulate HTML FORM components. JSObject win = (JSObject)JSObject.getWindow(this); JSObject inputText = (JSObject) win.eval("document.forms[0].elements[0]"); String value = (String)inputText.getMember("value"); // read form value inputText.setMember("value" , value + " new stuff"); // write form value But this action requires a signed applet. in Netscape, you must PrivilegeManager.enablePrivilege("UniversalBrowserRead"); PrivilegeManager.enablePrivilege("UniversalBrowserWrite"); before using an JSObject related to an HTML document. But there is a workaround, simply pass the informations through Javascript functions! [JSjava.java] [JSjava.html] For best result, never use LiveConnect JSObject in Applet's init() method.