Broadcasts are values sent from the driver to executors. They can be used for lookups, etc. and executors can only read them. Accumulators on the other hand are written to in executors, and read in the driver. They can be used for counts, sum of squares, etc.
object Main {
def main(args: Array[String]){
val sc = new SparkContext("local[*]", "hello-spark")
val rdd = sc.parallelize(1 to 1000, 4)
val div = 2.0
val bDiv = sc.broadcast(div)
val accum = sc.accumulator(0.0)
rdd.map(_ / bDiv.value)
.foreach(x => accum += x)
println(accum.value)
sc.stop()
}
}